Skip to content
Snippets Groups Projects
Commit 238478f5 authored by Stefan Bürk's avatar Stefan Bürk
Browse files

[FEATURE] Add new redirect `PageTypeSource` source type implementation

It's possible that project instances are configured to use
RouteEnhancers and RouteDecorators, e.g. PageTypeSuffix
RouteDecorater with a suffix for page type "0" (zero) like
".html". Until now, only the slug-field value has been used
as source path for auto created redirects, which neglected to
respect these route configuration possibilities. That means
that a proper redirect hasn't been create if for e.g. the
".html" suffix has been configured for page type "0".

Since #99188 introduced the "SlugRedirectChangeItemCreatedEvent"
it's possible to add further source types, for which redirects
are created.

This change provides the "PageTypeSource" as new generic source
type for page type based sources. The TYPO3 core adds a listener
to build an URI with page type "0" and adds this to the current
change item as source. This added `PageTypeSource` will replace
the `PlainSlugReplacementSource` if the source host and path
are the same - it overrules it to avoid duplicate redirects.
That means, if both are providing different source information
both are kept and two different redirects are created.

Extension authors can now use the new PageTypeSource type to
provide additional sources for other page types registering
a custom "SlugRedirectChangeItemCreatedEvent" listener - or
remove the "PlainSlugReplacementSource" if needed. With this
event based solution configuration options are kept simple.

Resolves: #94499
Related: #99746
Releases: main
Change-Id: Ic4feb8de1b05ba9d06dce2acaa0537ab39245e92
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77195


Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarStefan Froemken <froemken@gmail.com>
Tested-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: default avatarStefan Froemken <froemken@gmail.com>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
parent 0208c740
Branches
Tags
Showing with 769 additions and 8 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment