コード例 #1
0
 /**
  * Build the URI context classes into the given UriContextCollection.
  *
  * @param UriContextCollection $uriContextCollection
  */
 public function buildUriContextCollection(UriContextCollection $uriContextCollection)
 {
     $this->getUriContextsForDocument($uriContextCollection);
     foreach ($uriContextCollection->getUriContexts() as $uriContext) {
         $existingRoute = $this->adapter->findRouteForUri($uriContext->getUri(), $uriContext);
         $autoRoute = null;
         if ($existingRoute) {
             $autoRoute = $this->handleExistingRoute($existingRoute, $uriContext);
         }
         if (!$autoRoute) {
             $autoRouteTag = $this->adapter->generateAutoRouteTag($uriContext);
             $autoRoute = $this->adapter->createAutoRoute($uriContext, $uriContext->getSubjectObject(), $autoRouteTag);
         }
         $uriContext->setAutoRoute($autoRoute);
     }
     $this->pendingUriContextCollections[] = $uriContextCollection;
 }
コード例 #2
0
 /**
  * Build the URI context classes into the given UriContextCollection.
  *
  * @param UriContextCollection $uriContextCollection
  */
 public function buildUriContextCollection(UriContextCollection $uriContextCollection)
 {
     $this->collectionBuilder->build($uriContextCollection);
     foreach ($uriContextCollection->getUriContexts() as $uriContext) {
         $subject = $uriContextCollection->getSubjectObject();
         if (null !== $uriContext->getLocale()) {
             $translatedSubject = $this->adapter->translateObject($subject, $uriContext->getLocale());
             if (null === $translatedSubject) {
                 @trigger_error('AdapterInterface::translateObject() has to return the subject as of version 1.1, support for by reference will be removed in 2.0.', E_USER_DEPRECATED);
             } else {
                 if ($translatedSubject !== $subject) {
                     $uriContext->setTranslatedSubjectObject($translatedSubject);
                 }
             }
         }
         // generate the URI
         $uri = $this->uriGenerator->generateUri($uriContext);
         $uriContext->setUri($uri);
         $existingRoute = $this->adapter->findRouteForUri($uri, $uriContext);
         // handle existing route
         $autoRoute = null;
         if ($existingRoute) {
             $autoRoute = $this->handleExistingRoute($existingRoute, $uriContext);
         }
         // handle new route
         if (null === $autoRoute) {
             $autoRouteTag = $this->adapter->generateAutoRouteTag($uriContext);
             // TODO: The second argument below is now **pointless**, as the
             // UriContext contains both the original and translated subject
             // objects.
             //
             // See: https://github.com/symfony-cmf/RoutingAuto/issues/73
             $autoRoute = $this->adapter->createAutoRoute($uriContext, $subject, $autoRouteTag);
         }
         $uriContext->setAutoRoute($autoRoute);
     }
     $this->pendingUriContextCollections[] = $uriContextCollection;
 }