/**
  * {@inheritdoc}
  */
 public function findByRoute(RouteInterface $route)
 {
     foreach ($this->translations as $translation) {
         if (null !== $translation->getRoute() && $route->getId() === $translation->getRoute()->getId()) {
             return $translation;
         }
     }
     return null;
 }
Пример #2
0
 /**
  * Generate unique route.
  *
  * @param RouteInterface $route
  * @param bool $withSlash
  *
  * @return null|RouteInterface
  */
 public function generateUniqueRoute(RouteInterface $route, $withSlash = false)
 {
     $originalRoutePattern = $this->generateRouteFromText($route->getRoutePattern(), $withSlash);
     if ($originalRoutePattern) {
         $key = 0;
         $routePattern = $this->normalizeRoute($originalRoutePattern);
         while ($this->hasRoute($routePattern, $route->getName())) {
             $key++;
             $routePattern = $originalRoutePattern . '-' . $key;
         }
         $route->setRoutePattern($routePattern);
         return $route;
     }
     return null;
 }
Пример #3
0
 /**
  * Get unique route pattern.
  *
  * @param RouteInterface $route
  *
  * @return string
  */
 private function getUniqueRoutePattern(RouteInterface $route)
 {
     $key = 0;
     $originalRoutePattern = $this->routerHelper->normalizeRoutePattern($route->getRoutePattern());
     $routePattern = $originalRoutePattern;
     while ($this->hasRoute($route->getName(), $routePattern)) {
         $key++;
         $routePattern = $originalRoutePattern . '-' . $key;
     }
     return $routePattern;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function remove(RouteInterface $route, $save = false)
 {
     if (isset($this->routes[$route->getName()])) {
         unset($this->routes[$route->getName()]);
     }
     $this->routeManager->remove($route, $save);
 }