public function assemble(LocaleEvent $event) { $uri = $event->getUri(); $base = $this->getBasePath(); $locale = $event->getLocale(); $current = $this->getFirstSegmentInPath($uri, $base); if (!$this->redirectToCanonical() && null !== $this->getAliases()) { $alias = $this->getAliasForLocale($locale); if (null !== $alias) { $locale = $alias; } } $path = $uri->getPath(); // Last part of base is now always locale, remove that $parts = explode('/', $base); array_pop($parts); $base = implode('/', $parts); if ($base) { $path = substr($path, strlen($base)); } $parts = explode('/', trim($path, '/')); // Remove first part array_shift($parts); $path = $base . '/' . $locale . '/' . implode('/', $parts); $uri->setPath($path); return $uri; }
/** * {@inheritdoc} */ public function assemble(LocaleEvent $event) { $uri = $event->getUri(); $locale = $event->getLocale(); $query = $uri->getQueryAsArray(); $key = $this->getQueryKey(); $query[$key] = $locale; $uri->setQuery($query); return $uri; }
/** * {@inheritdoc} */ public function assemble(LocaleEvent $event) { $locale = $event->getLocale(); foreach ($this->getAliases() as $alias => $item) { if ($item == $locale) { $tld = $alias; } } if (!isset($tld)) { throw new InvalidArgumentException('No matching tld found for current locale'); } $port = $event->getRequest()->getServer()->get('SERVER_PORT'); $hostname = str_replace(self::LOCALE_KEY, $tld, $this->getDomain()); if (null !== $port && 80 != $port) { $hostname .= ':' . $port; } $uri = $event->getUri(); $uri->setHost($hostname); return $uri; }