PHP Class Neos\Flow\Mvc\Routing\IdentityRoutePart

This handler is used by default, if an objectType is specified for a route part in the routing configuration: - name: 'Some route for xyz entities' uriPattern: '{xyz}' routeParts: 'xyz': objectType: 'Some\Package\Domain\Model\Xyz'
See also: Neos\Flow\Mvc\Routing\ObjectPathMapping
Inheritance: extends DynamicRoutePart
显示文件 Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$objectPathMappingRepository ObjectPathMappingRepository
$objectType string The object type (class name) of the entity this route part belongs to
$persistenceManager Neos\Flow\Persistence\PersistenceManagerInterface
$reflectionService Neos\Flow\Reflection\ReflectionService
$uriPattern string pattern for the URI representation (for example "{date:Y}/{date:m}/{date.d}/{title}")

Public Methods

Method Description
getObjectType ( ) : string
getUriPattern ( ) : string If $this->uriPattern is specified, this will be returned, otherwise identity properties of $this->objectType are returned in the format {property1}/{property2}/{property3}.
setObjectType ( string $objectType ) : void
setUriPattern ( string $uriPattern ) : void

Protected Methods

Method Description
createPathSegmentForObject ( mixed $object ) : string Creates a URI representation (path segment) for the given object matching $this->uriPattern.
findValueToMatch ( string $routePath ) : string Returns the first part of $routePath that should be evaluated in matchValue().
getObjectIdentifierFromPathSegment ( string $pathSegment ) : string | integer Retrieves the object identifier from the given $pathSegment.
getPathSegmentByIdentifier ( string $identifier ) : string | integer Generates a unique string for the given identifier according to $this->uriPattern.
matchValue ( string $value ) : boolean Checks, whether given value can be matched.
resolveValue ( mixed $value ) : boolean Resolves the given entity and sets the value to a URI representation (path segment) that matches $this->uriPattern and is unique for the given object.
rewriteForUri ( string $value ) : string Transforms the given string into a URI compatible format without special characters.
storeObjectPathMapping ( string $pathSegment, string | integer $identifier ) : void Creates a new ObjectPathMapping and stores it in the repository

Method Details

createPathSegmentForObject() protected method

Creates a URI representation (path segment) for the given object matching $this->uriPattern.
protected createPathSegmentForObject ( mixed $object ) : string
$object mixed object of type $this->objectType
return string URI representation (path segment) of the given object

findValueToMatch() protected method

If no split string is set (route part is the last in the routes uriPattern), the complete $routePart is returned. Otherwise the part is returned that matches the specified uriPattern of this route part.
protected findValueToMatch ( string $routePath ) : string
$routePath string The request path to be matched
return string value to match, or an empty string if $routePath is empty, split string was not found or uriPattern could not be matched

getObjectIdentifierFromPathSegment() protected method

If no UriPattern is set, the $pathSegment is expected to be the (URL-encoded) identifier otherwise a matching ObjectPathMapping fetched from persistence If no matching ObjectPathMapping was found or the given $pathSegment is no valid identifier NULL is returned.
protected getObjectIdentifierFromPathSegment ( string $pathSegment ) : string | integer
$pathSegment string the query path segment to convert
return string | integer the technical identifier of the object or NULL if it couldn't be found

getObjectType() public method

public getObjectType ( ) : string
return string

getPathSegmentByIdentifier() protected method

If no UriPattern is set, the path segment is equal to the (URL-encoded) $identifier - otherwise a matching ObjectPathMapping is fetched from persistence. If no ObjectPathMapping exists for the given identifier, a new ObjectPathMapping is created.
protected getPathSegmentByIdentifier ( string $identifier ) : string | integer
$identifier string the technical identifier of the object
return string | integer the resolved path segment(s)

getUriPattern() public method

If $this->objectType does not contain identity properties, an empty string is returned.
public getUriPattern ( ) : string
return string

matchValue() protected method

If the value is empty, FALSE is returned. Otherwise the ObjectPathMappingRepository is asked for a matching ObjectPathMapping. If that is found the identifier is stored in $this->value, otherwise this route part does not match.
protected matchValue ( string $value ) : boolean
$value string value to match, usually the current query path segment(s)
return boolean TRUE if value could be matched successfully, otherwise FALSE

resolveValue() protected method

Resolves the given entity and sets the value to a URI representation (path segment) that matches $this->uriPattern and is unique for the given object.
protected resolveValue ( mixed $value ) : boolean
$value mixed
return boolean TRUE if the object could be resolved and stored in $this->value, otherwise FALSE.

rewriteForUri() protected method

In the long term this should be done with proper transliteration
protected rewriteForUri ( string $value ) : string
$value string
return string

setObjectType() public method

public setObjectType ( string $objectType ) : void
$objectType string
return void

setUriPattern() public method

public setUriPattern ( string $uriPattern ) : void
$uriPattern string
return void

storeObjectPathMapping() protected method

Creates a new ObjectPathMapping and stores it in the repository
protected storeObjectPathMapping ( string $pathSegment, string | integer $identifier ) : void
$pathSegment string
$identifier string | integer
return void

Property Details

$objectPathMappingRepository protected_oe property

protected ObjectPathMappingRepository,Neos\Flow\Mvc\Routing $objectPathMappingRepository
return ObjectPathMappingRepository

$objectType protected_oe property

The object type (class name) of the entity this route part belongs to
protected string $objectType
return string

$persistenceManager protected_oe property

protected PersistenceManagerInterface,Neos\Flow\Persistence $persistenceManager
return Neos\Flow\Persistence\PersistenceManagerInterface

$reflectionService protected_oe property

protected ReflectionService,Neos\Flow\Reflection $reflectionService
return Neos\Flow\Reflection\ReflectionService

$uriPattern protected_oe property

pattern for the URI representation (for example "{date:Y}/{date:m}/{date.d}/{title}")
protected string $uriPattern
return string