Neos\Flow\Mvc\Routing\ObjectPathMappingRepository::findOneByObjectTypeUriPatternAndIdentifier PHP Méthode

findOneByObjectTypeUriPatternAndIdentifier() public méthode

public findOneByObjectTypeUriPatternAndIdentifier ( string $objectType, string $uriPattern, string | integer $identifier ) : ObjectPathMapping
$objectType string the object type of the ObjectPathMapping object
$uriPattern string the URI pattern of the ObjectPathMapping object
$identifier string | integer the identifier of the object, for example the UUID, @see \Neos\Flow\Persistence\PersistenceManagerInterface::getIdentifierByObject()
Résultat ObjectPathMapping
    public function findOneByObjectTypeUriPatternAndIdentifier($objectType, $uriPattern, $identifier)
    {
        $query = $this->createQuery();
        return $query->matching($query->logicalAnd($query->equals('objectType', $objectType), $query->equals('uriPattern', $uriPattern), $query->equals('identifier', $identifier)))->execute()->getFirst();
    }

Usage Example

 /**
  * Generates a unique string for the given identifier according to $this->uriPattern.
  * 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.
  *
  * @param string $identifier the technical identifier of the object
  * @return string|integer the resolved path segment(s)
  * @throws InfiniteLoopException if no unique path segment could be found after 100 iterations
  */
 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;
 }