/** * {@inheritDoc} */ public function handleDefunctRoutes(UriContextCollection $uriContextCollection) { $subject = $uriContextCollection->getSubjectObject(); $realClassName = $this->adapter->getRealClassName(get_class($uriContextCollection->getSubjectObject())); $metadata = $this->metadataFactory->getMetadataForClass($realClassName); $defunctRouteHandlerConfig = $metadata->getDefunctRouteHandler(); $defunctHandler = $this->serviceRegistry->getDefunctRouteHandler($defunctRouteHandlerConfig['name']); $defunctHandler->handleDefunctRoutes($uriContextCollection); }
/** * Populates an empty UriContextCollection with UriContexts * * @param $uriContextCollection UriContextCollection */ private function getUriContextsForDocument(UriContextCollection $uriContextCollection) { $locales = $this->adapter->getLocales($uriContextCollection->getSubjectObject()) ?: array(null); foreach ($locales as $locale) { if (null !== $locale) { $this->adapter->translateObject($uriContextCollection->getSubjectObject(), $locale); } // create and add uri context to stack $uriContext = $uriContextCollection->createUriContext($locale); $uriContextCollection->addUriContext($uriContext); // generate the URL $uri = $this->uriGenerator->generateUri($uriContext); // update the context with the URL $uriContext->setUri($uri); } }
/** * {@inheritDoc} */ public function handleDefunctRoutes(UriContextCollection $uriContextCollection) { $referringAutoRouteCollection = $this->adapter->getReferringAutoRoutes($uriContextCollection->getSubjectObject()); foreach ($referringAutoRouteCollection as $referringAutoRoute) { if (false === $uriContextCollection->containsAutoRoute($referringAutoRoute)) { $newRoute = $uriContextCollection->getAutoRouteByTag($referringAutoRoute->getAutoRouteTag()); $this->adapter->createRedirectRoute($referringAutoRoute, $newRoute); } } }
/** * {@inheritdoc} */ public function handleDefunctRoutes(UriContextCollection $uriContextCollection) { $referringAutoRouteCollection = $this->adapter->getReferringAutoRoutes($uriContextCollection->getSubjectObject()); foreach ($referringAutoRouteCollection as $referringAutoRoute) { if (false === $uriContextCollection->containsAutoRoute($referringAutoRoute)) { $newRoute = $uriContextCollection->getAutoRouteByTag($referringAutoRoute->getAutoRouteTag()); if (null !== $newRoute) { $this->adapter->migrateAutoRouteChildren($referringAutoRoute, $newRoute); } $this->adapter->removeAutoRoute($referringAutoRoute); } } }
/** * Populates an empty UriContextCollection with UriContexts. * * @param $uriContextCollection UriContextCollection */ public function build(UriContextCollection $uriContextCollection) { $subjectObject = $uriContextCollection->getSubjectObject(); $realClassName = $this->adapter->getRealClassName(get_class($subjectObject)); $metadata = $this->metadataFactory->getMetadataForClass($realClassName); // TODO: This is where we will call $metadata->getUriSchemas() which will return an // array of URI schemas (inc. the "template", TP configs and CR configs). $definitions = $metadata->getAutoRouteDefinitions(); foreach ($definitions as $definition) { $locales = $this->adapter->getLocales($subjectObject) ?: array(null); foreach ($locales as $locale) { // create and add uri context to stack $uriContext = $uriContextCollection->createUriContext($definition->getUriSchema(), $definition->getDefaults(), $metadata->getTokenProviders(), $metadata->getConflictResolver(), $locale); $uriContextCollection->addUriContext($uriContext); } } }
/** * Populates an empty UriContextCollection with UriContexts. * * @param $uriContextCollection UriContextCollection */ private function getUriContextsForDocument(UriContextCollection $uriContextCollection) { $locales = $this->adapter->getLocales($uriContextCollection->getSubjectObject()) ?: array(null); foreach ($locales as $locale) { if (null !== $locale) { $subjectObject = $this->adapter->translateObject($uriContextCollection->getSubjectObject(), $locale); if (null !== $subjectObject) { $uriContextCollection->setSubjectObject($subjectObject); } else { @trigger_error('AdapterInterface::translateObject() has to return the subjectObject as of version 1.1, support for by reference will be removed in 2.0.', E_USER_DEPRECATED); } } // create and add uri context to stack $uriContext = $uriContextCollection->createUriContext($locale); $uriContextCollection->addUriContext($uriContext); // generate the URL $uri = $this->uriGenerator->generateUri($uriContext); // update the context with the URL $uriContext->setUri($uri); } }