/**
  * Handle the case where the generated path already exists.
  * Either if it does not reference the same content then we
  * have a conflict which needs to be resolved.
  *
  * @param Route      $route
  * @param UriContext $uriContext
  */
 private function handleExistingRoute($existingRoute, $uriContext)
 {
     $isSameContent = $this->adapter->compareAutoRouteContent($existingRoute, $uriContext->getSubjectObject());
     if ($isSameContent) {
         $autoRoute = $existingRoute;
         $autoRoute->setType(AutoRouteInterface::TYPE_PRIMARY);
         return $autoRoute;
     }
     $uri = $this->uriGenerator->resolveConflict($uriContext);
     $uriContext->setUri($uri);
 }
 /**
  * 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);
     }
 }