class FrontendNodeRoutePartHandler extends DynamicRoutePart implements FrontendNodeRoutePartHandlerInterface (View source)

A route part handler for finding nodes specifically in the website's frontend.

Constants

DIMENSION_REQUEST_PATH_MATCHER

Properties

protected LoggerInterface $systemLogger
protected ContentContextFactory $contextFactory
protected Context $securityContext
protected DomainRepository $domainRepository
protected SiteRepository $siteRepository
protected bool $supportEmptySegmentForDimensions
protected ContentDimensionPresetSourceInterface $contentDimensionPresetSource

Methods

string
findValueToMatch(string $requestPath)

Extracts the node path from the request path.

bool
matchValue(string $requestPath)

Matches a frontend URI pointing to a node (for example a page).

convertRequestPathToNode(string $requestPath)

Returns the initialized node that is referenced by $requestPath, based on the node's "uriPathSegment" property.

bool
resolveValue(mixed $node)

Checks, whether given value is a Node object and if so, sets $this->value to the respective node path.

buildContextFromRequestPath(string $requestPath)

Creates a content context from the given request path, considering possibly mentioned content dimension values.

buildContextFromPath(string $path, bool $convertLiveDimensions)

Creates a content context from the given "context path", i.e. a string used for resolving (not matching) a node.

buildContextFromWorkspaceName(string $workspaceName, array $dimensions = null)

No description

string
removeContextFromPath(string $path)

No description

bool
onlyMatchSiteNodes()

Whether the current route part should only match/resolve site nodes (e.g. the homepage)

string
resolveRoutePathForNode(NodeInterface $node)

Resolves the request path, also known as route path, identifying the given node.

string
getRelativeNodePathByUriPathSegmentProperties(NodeInterface $siteNode, string $relativeRequestPath)

Builds a node path which matches the given request path.

string
getRequestPathByNode(NodeInterface $node)

Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node.

array
parseDimensionsAndNodePathFromRequestPath(string $requestPath)

Choose between default method for parsing dimensions or the one which allows uriSegment to be empty for default preset.

array
parseDimensionsAndNodePathFromRequestPathAllowingEmptySegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

array
parseDimensionsAndNodePathFromRequestPathAllowingNonUniqueSegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

buildContextFromWorkspaceNameAndDimensions(string $workspaceName, array $dimensionsAndDimensionValues)

Sets context properties like "invisibleContentShown" according to the workspace (live or not) and returns a ContentContext object.

string
getUriSegmentForDimensions(array $dimensionsValues, bool $currentNodeIsSiteNode)

Find a URI segment in the content dimension presets for the given "language" dimension values

Details

protected string findValueToMatch(string $requestPath)

Extracts the node path from the request path.

Parameters

string $requestPath

The request path to be matched

Return Value

string

value to match, or an empty string if $requestPath is empty or split string was not found

protected bool matchValue(string $requestPath)

Matches a frontend URI pointing to a node (for example a page).

This function tries to find a matching node by the given request path. If one was found, its absolute context node path is set in $this->value and true is returned.

Note that this matcher does not check if access to the resolved workspace or node is allowed because at the point in time the route part handler is invoked, the security framework is not yet fully initialized.

Parameters

string $requestPath

The request path (without leading "/", relative to the current Site Node)

Return Value

bool

true if the $requestPath could be matched, otherwise false

Exceptions

Exception
NoHomepageException

protected NodeInterface convertRequestPathToNode(string $requestPath)

Returns the initialized node that is referenced by $requestPath, based on the node's "uriPathSegment" property.

Note that $requestPath will be modified (passed by reference) by buildContextFromRequestPath().

Parameters

string $requestPath

The request path, for example /the/node/path@some-workspace

Return Value

NodeInterface

Exceptions

NoWorkspaceException
NoSiteException
NoSuchNodeException
NoSiteNodeException
InvalidRequestPathException

protected bool resolveValue(mixed $node)

Checks, whether given value is a Node object and if so, sets $this->value to the respective node path.

In order to render a suitable frontend URI, this function strips off the path to the site node and only keeps the actual node path relative to that site node. In practice this function would set $this->value as follows:

absolute node path: /sites/neostypo3org/homepage/about $this->value: homepage/about

absolute node path: /sites/neostypo3org/homepage/about@user-admin $this->value: homepage/about@user-admin

Parameters

mixed $node

Either a Node object or an absolute context node path

Return Value

bool

true if value could be resolved successfully, otherwise false.

protected ContentContext buildContextFromRequestPath(string $requestPath)

Creates a content context from the given request path, considering possibly mentioned content dimension values.

Parameters

string $requestPath

The request path. If at least one content dimension is configured, the first path segment will identify the content dimension values

Return Value

ContentContext

The built content context

protected ContentContext buildContextFromPath(string $path, bool $convertLiveDimensions)

Creates a content context from the given "context path", i.e. a string used for resolving (not matching) a node.

Parameters

string $path

a path containing the context, such as /sites/examplecom/home@user-johndoe or /assets/pictures/my-picture or /assets/pictures/my-picture@user-john;language=de&country=global

bool $convertLiveDimensions

Whether to parse dimensions from the context path in a non-live workspace

Return Value

ContentContext

based on the specified path; only evaluating the context information (i.e. everything after "@")

Exceptions

InvalidRequestPathException

protected ContentContext buildContextFromWorkspaceName(string $workspaceName, array $dimensions = null)

No description

Parameters

string $workspaceName
array $dimensions

Return Value

ContentContext

protected string removeContextFromPath(string $path)

No description

Parameters

string $path

an absolute or relative node path which possibly contains context information, for example "/sites/somesite/the/node/path@some-workspace"

Return Value

string

the same path without context information

protected bool onlyMatchSiteNodes()

Whether the current route part should only match/resolve site nodes (e.g. the homepage)

Return Value

bool

protected string resolveRoutePathForNode(NodeInterface $node)

Resolves the request path, also known as route path, identifying the given node.

A path is built, based on the uri path segment properties of the parents of and the given node itself. If content dimensions are configured, the first path segment will the identifiers of the dimension values according to the current context.

Parameters

NodeInterface $node

The node where the generated path should lead to

Return Value

string

The relative route path, possibly prefixed with a segment for identifying the current content dimension values

protected string getRelativeNodePathByUriPathSegmentProperties(NodeInterface $siteNode, string $relativeRequestPath)

Builds a node path which matches the given request path.

This method traverses the segments of the given request path and tries to find nodes on the current level which have a matching "uriPathSegment" property. If no node could be found which would match the given request path, false is returned.

Parameters

NodeInterface $siteNode

The site node, used as a starting point while traversing the tree

string $relativeRequestPath

The request path, relative to the site's root path

Return Value

string

Exceptions

NoSuchNodeException

protected string getRequestPathByNode(NodeInterface $node)

Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node.

Parameters

NodeInterface $node

The node where the generated path should lead to

Return Value

string

A relative request path

Exceptions

MissingNodePropertyException

protected array parseDimensionsAndNodePathFromRequestPath(string $requestPath)

Choose between default method for parsing dimensions or the one which allows uriSegment to be empty for default preset.

Parameters

string $requestPath

The request path currently being processed by this route part handler, e.g. "de_global/startseite/ueber-uns"

Return Value

array

An array of dimension name => dimension values (array of string)

protected array parseDimensionsAndNodePathFromRequestPathAllowingEmptySegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

Allows uriSegment to be empty for default dimension preset.

If the first path segment contained content dimension information, it is removed from &$requestPath.

Parameters

string $requestPath

The request path currently being processed by this route part handler, e.g. "de_global/startseite/ueber-uns"

Return Value

array

An array of dimension name => dimension values (array of string)

Exceptions

InvalidDimensionPresetCombinationException

protected array parseDimensionsAndNodePathFromRequestPathAllowingNonUniqueSegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

Doesn't allow empty uriSegment, but allows uriSegment to be not unique across presets.

If the first path segment contained content dimension information, it is removed from &$requestPath.

Parameters

string $requestPath

The request path currently being processed by this route part handler, e.g. "de_global/startseite/ueber-uns"

Return Value

array

An array of dimension name => dimension values (array of string)

Exceptions

InvalidDimensionPresetCombinationException
InvalidRequestPathException
NoSuchDimensionValueException

protected ContentContext buildContextFromWorkspaceNameAndDimensions(string $workspaceName, array $dimensionsAndDimensionValues)

Sets context properties like "invisibleContentShown" according to the workspace (live or not) and returns a ContentContext object.

Parameters

string $workspaceName

Name of the workspace to use in the context

array $dimensionsAndDimensionValues

An array of dimension names (index) and their values (array of strings). See also: ContextFactory

Return Value

ContentContext

protected string getUriSegmentForDimensions(array $dimensionsValues, bool $currentNodeIsSiteNode)

Find a URI segment in the content dimension presets for the given "language" dimension values

This will do a reverse lookup from actual dimension values to a preset and fall back to the default preset if none can be found.

Parameters

array $dimensionsValues

An array of dimensions and their values, indexed by dimension name

bool $currentNodeIsSiteNode

If the current node is actually the site node

Return Value

string

Exceptions

Exception