public function getRoutesByNames($names, $parameters = []) { $collection = $this->repository->findBy([], null, self::CANDIDATES_LIMIT); $routes = []; foreach ($collection as $item) { $routes[] = $this->getRouteByName($item->getId()); } return $routes; }
public function getRoutesByNames($names, $parameters = []) { $collection = $this->repository->matching(new Criteria()); $routes = []; $collection->map(function (RouteInterface $route) use(&$routes) { $routes[] = $this->getRouteByName($route->getId()); }); return $routes; }
public function getRoutesByNames($names, $parameters = []) { $collection = $this->repository->findAll(); $routes = []; foreach ($collection as $item) { $routes[] = $this->getRouteByName($item->getId()); } return $routes; }
/** * Validate the route entity * * @param mixed $entity * @param Constraint $constraint */ public function validate($entity, Constraint $constraint) { if (!$entity instanceof RoutableSubjectInterface) { throw new \InvalidArgumentException(sprintf('Expected instance of %s', RoutableSubjectInterface::class)); } $route = $entity->getRoute(); $slug = $entity->getSlug(); $locale = $entity->getLocale(); $result = $this->routeRepository->findOneBy(['path' => $slug, 'locale' => $locale]); // route is unique always if no result was found if (null === $result) { return; } // skip validation if there is exact match if ($route instanceof RouteInterface && $result->getIdentifier()->getId() === $route->getIdentifier()->getId()) { return; } if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message)->setParameter('{{ type }}', $this->formatValue($result->getType()))->setParameter('{{ url }}', $this->generatePath($result))->atPath('slug')->setInvalidValue($slug)->addViolation(); } }