Review main Merged

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

Stefan Froemken CR +2 V +2 Hard +769 −8 updated 03/27/23, 14:53

Commit message

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.

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 2

Files 8