Exemple #1
0
 /**
  * @return array
  */
 private function delocalizePath()
 {
     $this->assertUrlExists();
     if (!isset($this->parsed['path'])) {
         return null;
     }
     $path_segments = explode('/', trim($this->parsed['path'], '/'));
     if (count($path_segments) < 1) {
         return null;
     }
     if ($path_segments[0] == $this->locale->getSlug($path_segments[0]) || $this->locale->isHidden($path_segments[0])) {
         unset($path_segments[0]);
     }
     return '/' . implode('/', $path_segments);
 }
Exemple #2
0
 /**
  * @param $parsed
  * @return array
  */
 private function cleanPathFromExistingLocale($parsed)
 {
     if (!isset($parsed['path'])) {
         return null;
     }
     $path_segments = explode('/', trim($parsed['path'], '/'));
     if (count($path_segments) < 1) {
         return null;
     }
     if ($path_segments[0] == $this->locale->getSlug($path_segments[0]) || $this->locale->isHidden($path_segments[0])) {
         unset($path_segments[0]);
     }
     return '/' . implode('/', $path_segments);
 }
Exemple #3
0
 /**
  * Isolate locale value from parameters
  *
  * @param array $parameters
  * @return null|string
  */
 private function extractLocaleFromParameters(&$parameters = [])
 {
     $locale = null;
     if (!is_array($parameters)) {
         $locale = $this->locale->get($parameters);
         // If locale is the only parameter, we make sure the 'real' parameters is flushed
         if ($locale == $parameters) {
             $parameters = [];
         }
         return $locale;
     }
     if (!array_key_exists($this->placeholder, $parameters)) {
         return $this->locale->get();
     }
     $locale = $this->locale->get($parameters[$this->placeholder]);
     // If locale parameter is not a 'real' parameters, we ignore the passed locale and use the active one
     // The 'wrong' parameter will be used without key
     if ($locale != $parameters[$this->placeholder]) {
         $parameters[] = $parameters[$this->placeholder];
     }
     unset($parameters[$this->placeholder]);
     return $locale;
 }