Neos\Flow\Mvc\Routing\IdentityRoutePart::getPathSegmentByIdentifier PHP Method

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)
    protected function getPathSegmentByIdentifier($identifier)
    {
        if ($this->getUriPattern() === '') {
            return rawurlencode($identifier);
        }
        $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndIdentifier($this->objectType, $this->getUriPattern(), $identifier);
        if ($objectPathMapping !== null) {
            return $this->lowerCase ? strtolower($objectPathMapping->getPathSegment()) : $objectPathMapping->getPathSegment();
        }
        $object = $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType);
        $pathSegment = $uniquePathSegment = $this->createPathSegmentForObject($object);
        $pathSegmentLoopCount = 0;
        do {
            if ($pathSegmentLoopCount++ > 99) {
                throw new InfiniteLoopException('No unique path segment could be found after ' . ($pathSegmentLoopCount - 1) . ' iterations.', 1316441798);
            }
            if ($uniquePathSegment !== '') {
                $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndPathSegment($this->objectType, $this->getUriPattern(), $uniquePathSegment, !$this->lowerCase);
                if ($objectPathMapping === null) {
                    $this->storeObjectPathMapping($uniquePathSegment, $identifier);
                    break;
                }
            }
            $uniquePathSegment = sprintf('%s-%d', $pathSegment, $pathSegmentLoopCount);
        } while (true);
        return $this->lowerCase ? strtolower($uniquePathSegment) : $uniquePathSegment;
    }