Example #1
0
 /**
  * {@inheritDoc}
  */
 public function getRouteByName($name)
 {
     if (!$this->candidatesStrategy->isCandidate($name)) {
         throw new RouteNotFoundException(sprintf('Route "%s" is not handled by this route provider', $name));
     }
     $route = $this->getRouteRepository()->findOneBy(array('name' => $name));
     if (!$route) {
         throw new RouteNotFoundException("No route found for name '{$name}'");
     }
     return $route;
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function getRoutesByNames($names = null)
 {
     if (null === $names) {
         return $this->getAllRoutes();
     }
     $candidates = array();
     foreach ($names as $key => $name) {
         if (UUIDHelper::isUUID($name) || $this->candidatesStrategy->isCandidate($name)) {
             $candidates[$key] = $name;
         }
     }
     if (!$candidates) {
         return array();
     }
     /** @var $dm DocumentManager */
     $dm = $this->getObjectManager();
     $documents = $dm->findMany($this->className, $candidates);
     foreach ($documents as $key => $document) {
         if (UUIDHelper::isUUID($key) && !$this->candidatesStrategy->isCandidate($this->getObjectManager()->getUnitOfWork()->getDocumentId($document))) {
             // this uuid pointed out of our path. can only determine after fetching the document
             unset($documents[$key]);
         }
         if (!$document instanceof SymfonyRoute) {
             // we follow the logic of DocumentManager::findMany and do not throw an exception
             unset($documents[$key]);
         }
     }
     return $documents;
 }