/** * {@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; }
/** * Will create a symfony route. * * @param RouteInterface $route * @param Request $request * * @return Route */ protected function createRoute(RouteInterface $route, Request $request) { $routePath = $this->requestAnalyzer->getResourceLocatorPrefix() . $route->getPath(); if ($route->isHistory()) { return new Route($routePath, ['_controller' => 'SuluWebsiteBundle:Redirect:redirect', 'url' => $request->getSchemeAndHttpHost() . $this->requestAnalyzer->getResourceLocatorPrefix() . $route->getTarget()->getPath() . ($request->getQueryString() ? '?' . $request->getQueryString() : '')]); } $symfonyRoute = $this->proxyFactory->createProxy(Route::class, function (&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) use($routePath, $route, $request) { $initializer = null; // disable initialization $wrappedObject = new Route($routePath, $this->routeDefaultsProvider->getByEntity($route->getEntityClass(), $route->getEntityId(), $request->getLocale())); return true; }); return $this->symfonyRouteCache[$route->getId()] = $symfonyRoute; }