PersistedPatternMapper

class \TYPO3\CMS\Core\Routing\Aspect\PersistedPatternMapper

Implements
PersistedMappableAspectInterface, StaticMappableAspectInterface, ContextAwareInterface, SiteLanguageAwareInterface, SiteAwareInterface
Uses
AspectTrait, SiteLanguageAccessorTrait, SiteAccessorTrait, ContextAwareTrait

Very useful for building an a path segment from a combined value of the database.

Please note: title is not prepared for slugs and used raw.

Example: routeEnhancers: EventsPlugin: type: Extbase extension: Events2 plugin: Pi1 routes: - { routePath: '/events/{event}', _controller: 'Event::detail', _arguments: {'event': 'event_name'}} defaultController: 'Events2::list' aspects: event: type: PersistedPatternMapper tableName: 'tx_events2_domain_model_event' routeFieldPattern: '^(?P<title>.+)-(?P\d+)$' routeFieldResult: '{title}-{uid}'

Table of Contents

Interfaces

PersistedMappableAspectInterface
Used for anything that invokes (more expensive) persistence invocations.
StaticMappableAspectInterface
Used for anything that has a fixed list of values mapped against route arguments.
ContextAwareInterface
SiteLanguageAwareInterface
Interface for SiteLanguageAware features of TYPO3
SiteAwareInterface
Interface for SiteAware features of TYPO3

Constants

PATTERN_RESULT  : mixed = '#\{(?P<fieldName>[^}]+)\}#'

Properties

$context  : Context
$languageAspect  : LanguageAspect
$languageFieldName  : string|null
$languageParentFieldName  : string|null
$routeFieldPattern  : string
$routeFieldResult  : string
$routeFieldResultNames  : string[]
$settings  : array
$site  : Site
$siteMatcher  : SiteMatcher|null
$slugUniqueInSite  : bool
$tableName  : string

Methods

__construct()  : mixed
generate()  : string|null
getContext()  : Context
getSite()  : Site
resolve()  : string|null
setContext()  : void
setSite()  : void
createPageRepository()  : PageRepository
createQueryBuilder()  : QueryBuilder
createRouteFieldConstraints()  : array
createRouteResult()  : string|null
filterContainedInSite()  : array
Filters records that are contained in current site (resolved from current SiteLanguage).
filterNamesKeys()  : array
findByIdentifier()  : array|null
findByRouteFieldValues()  : array|null
getLanguageAspect()  : LanguageAspect
Provides LanguageAspect which contains the logic how fallbacks for a given context/overlay-mode shall be handled.
getSiteMatcher()  : SiteMatcher
hasSlugUniqueInSite()  : bool
isPageIdContainedInSite()  : bool
Determines whether page is contained in current site (resolved from current SiteLanguage).
isSlugUniqueInSite()  : bool
resolveAllRelevantLanguageIds()  : int[]
Resolves all language ids that are relevant to retrieve the most specific variant of a record.
resolveLanguageFallback()  : array|null
Resolves one record out of given language fallbacks.
resolveOverlay()  : array|null

Constants

PATTERN_RESULT

protected mixed PATTERN_RESULT = '#\{(?P<fieldName>[^}]+)\}#'

Properties

$languageFieldName

protected string|null $languageFieldName

$languageParentFieldName

protected string|null $languageParentFieldName

$routeFieldPattern

protected string $routeFieldPattern

$routeFieldResult

protected string $routeFieldResult

$routeFieldResultNames

protected string[] $routeFieldResultNames

$slugUniqueInSite

protected bool $slugUniqueInSite

Methods

__construct()

public __construct(array $settings) : mixed

Parameters

$settings : array

Tags

throws
InvalidArgumentException

generate()

public generate(string $value) : string|null

Parameters

$value : string

Return values

string|null

resolve()

public resolve(string $value) : string|null

Parameters

$value : string

Return values

string|null

createRouteFieldConstraints()

protected createRouteFieldConstraints(QueryBuilder $queryBuilder, array $values) : array

Parameters

$queryBuilder : QueryBuilder
$values : array

Return values

array

createRouteResult()

protected createRouteResult(array|null $result) : string|null

Parameters

$result : array|null

Tags

throws
InvalidArgumentException

Return values

string|null

filterContainedInSite()

Filters records that are contained in current site (resolved from current SiteLanguage).

protected filterContainedInSite(array $results) : array

Results keep original indexes and probably needs to be passed through array_values for e.g. using the first result by $results[0].

Parameters

$results : array

Return values

array

filterNamesKeys()

protected filterNamesKeys(array $array) : array

Parameters

$array : array

Return values

array

findByIdentifier()

protected findByIdentifier(string $value) : array|null

Parameters

$value : string

Return values

array|null

findByRouteFieldValues()

protected findByRouteFieldValues(array $values) : array|null

Parameters

$values : array

Return values

array|null

getLanguageAspect()

Provides LanguageAspect which contains the logic how fallbacks for a given context/overlay-mode shall be handled.

protected getLanguageAspect() : LanguageAspect

Tags

see
LanguageAspectFactory::createFromSiteLanguage

Return values

LanguageAspect

hasSlugUniqueInSite()

protected hasSlugUniqueInSite(string $tableName, string ...$fieldNames) : bool

Parameters

$tableName : string
$fieldNames : string

Return values

bool

isPageIdContainedInSite()

Determines whether page is contained in current site (resolved from current SiteLanguage).

protected isPageIdContainedInSite(int $pageId) : bool

Parameters

$pageId : int

Return values

bool

isSlugUniqueInSite()

protected isSlugUniqueInSite(string $tableName, string $fieldName) : bool

Parameters

$tableName : string
$fieldName : string

Return values

bool

resolveAllRelevantLanguageIds()

Resolves all language ids that are relevant to retrieve the most specific variant of a record.

protected resolveAllRelevantLanguageIds() : int[]

The order of these ids defines the processing order concerning language fallback - most specific language comes first in this array.

  • "all language (-1)", most specific if present since there cannot be any localizations
  • "current language" most specific for the current given request context
  • "language fallbacks" falling back to language alternatives (might include "default language")

Return values

int[]

resolveLanguageFallback()

Resolves one record out of given language fallbacks.

protected resolveLanguageFallback(array $results, string|null $languageFieldName, array|null $languageIds) : array|null

Parameters

$results : array
$languageFieldName : string|null
$languageIds : array|null

Return values

array|null

resolveOverlay()

protected resolveOverlay(array|null $record) : array|null

Parameters

$record : array|null

Return values

array|null
On this page