Returns route-entity by route.
public findByPath ( string $path, string $locale ) : Sulu\Bundle\RouteBundle\Model\RouteInterface | ||
$path | string | |
$locale | string | |
return | Sulu\Bundle\RouteBundle\Model\RouteInterface |
/** * {@inheritdoc} */ public function resolve(RouteInterface $route) { $i = 1; $path = $route->getPath(); $conflict = $this->routeRepository->findByPath($route->getPath(), $route->getLocale()); while ($conflict) { if ($conflict && $conflict->getEntityClass() === $route->getEntityClass() && $conflict->getEntityId() == $route->getEntityId()) { // if conflict is found but has the same entity relation return this instead of the newly created route. return $conflict; } $route->setPath($path . '-' . $i++); $conflict = $this->routeRepository->findByPath($route->getPath(), $route->getLocale()); } return $route; }
/** * Find route and cache it. * * @param string $path * @param string $locale * * @return SuluRoute */ private function findRouteByPath($path, $locale) { $path = '/' . ltrim($path, '/'); if (!array_key_exists($path, $this->routeCache)) { $this->routeCache[$path] = $this->routeRepository->findByPath($path, $locale); } return $this->routeCache[$path]; }