示例#1
0
 public function resolveLocale()
 {
     $this->setLocale($this->defaultLocale);
     $request = $this->requestStack->getMasterRequest();
     if ($request !== null) {
         $path = new HierarchicalPath($request->getPathInfo());
         $segment = $path->getSegment(0);
         if (!empty($segment) && in_array($segment, $this->locales)) {
             $this->setLocale($segment);
         }
     }
 }
示例#2
0
 /**
  * Return the resolve URI with a updated path and query
  *
  * @param LeagueUriInterface|UriInterface $relative    the relative URI
  * @param string                          $pathString  the relative path string
  * @param string                          $queryString the relative query string
  *
  * @return LeagueUriInterface|UriInterface
  */
 protected function resolveRelativePath($relative, $pathString, $queryString)
 {
     $relativePath = new HierarchicalPath($pathString);
     if ($relativePath->isAbsolute()) {
         return $this->getBaseUri($relative)->withPath($relativePath->__toString())->withQuery($queryString);
     }
     $originalUri = $relativePath->modify($this->uri->getPath());
     $segments = $originalUri->toArray();
     array_pop($segments);
     $isAbsolute = HierarchicalPath::IS_RELATIVE;
     if (empty($originalUri->__toString()) || $originalUri->isAbsolute()) {
         $isAbsolute = HierarchicalPath::IS_ABSOLUTE;
     }
     $relativePath = $relativePath->createFromArray(array_merge($segments, $relativePath->toArray()), $isAbsolute);
     return $this->getBaseUri($relative)->withPath($relativePath->__toString())->withQuery($queryString);
 }