示例#1
0
 /**
  * Generates a url given the name of a route.
  *
  * @see    Zend\Mvc\Router\RouteInterface::assemble()
  * @param  string               $name               Name of the route
  * @param  array                $params             Parameters for the link
  * @param  array|\Traversable    $options            Options for the route
  * @param  bool                 $reuseMatchedParams Whether to reuse matched parameters
  * @return string Url                         For the link href attribute
  * @throws Exception\RuntimeException         If no RouteStackInterface was provided
  * @throws Exception\RuntimeException         If no RouteMatch was provided
  * @throws Exception\RuntimeException         If RouteMatch didn't contain a matched route name
  * @throws Exception\InvalidArgumentException If the params object was not an array or \Traversable object
  */
 public function __invoke($name = null, $params = [], $options = [], $reuseMatchedParams = false)
 {
     $url = parent::__invoke($name, $params, $options, $reuseMatchedParams);
     $locale = $this->moduleOptions->getCurrentLocale();
     if (isset($params['locale'])) {
         $locale = $params['locale'];
     }
     $url = '/' . $locale . $url;
     return $url;
 }
 /**
  * Get alias (if exists) from locale, otherwise return locale
  *
  * @param string $locale
  *
  * @return string
  * @throws LocaleNotFoundException
  */
 public function getAliasFromLocale($locale)
 {
     $locale = $this->getLocaleFromOptionsByKey($locale);
     $alias = array_search($locale, $this->moduleOptions->getAvailable());
     if (is_string($alias)) {
         return $alias;
     }
     return $locale;
 }