/**
  * Returns current runtime locale.
  *
  * @return string
  */
 public function __invoke()
 {
     $locale = $this->localeManager->getLocale();
     $locale = str_replace('_', '-', $locale);
     return $locale;
 }
 /**
  * assemble(): defined by \Zend\Mvc\Router\RouteInterface interface.
  *
  * @see    \Zend\Mvc\Router\RouteInterface::assemble()
  * @param  array $params
  * @param  array $options
  * @return mixed
  * @throws Exception\InvalidArgumentException
  * @throws Exception\RuntimeException
  */
 public function assemble(array $params = array(), array $options = array())
 {
     if (!isset($options['name'])) {
         throw new Exception\InvalidArgumentException('Missing "name" option');
     }
     $names = explode('/', $options['name'], 2);
     $route = $this->routes->get($names[0]);
     if (!$route) {
         throw new Exception\RuntimeException(sprintf('Route with name "%s" not found', $names[0]));
     }
     if (isset($names[1])) {
         if (!$route instanceof TreeRouteStack) {
             //die("DEBUG: route is " . gettype($route));
             throw new Exception\RuntimeException(sprintf('Route with name "%s" does not have child routes', $names[0]));
         }
         $options['name'] = $names[1];
     } else {
         unset($options['name']);
     }
     // Translator options
     if ($this->hasTranslator() && $this->isTranslatorEnabled()) {
         $options['translator'] = isset($options['translator']) ? $options['translator'] : $this->getTranslator();
         $options['text_domain'] = isset($options['text_domain']) ? $options['text_domain'] : $this->getTranslatorTextDomain();
         $options['locale'] = isset($options['locale']) ? $options['locale'] : str_replace('-', '_', $this->localeManager->getLocale());
     }
     if (isset($options['only_return_path']) && $options['only_return_path']) {
         return $this->getBaseUrlWithLocale($options['locale']) . $route->assemble(array_merge($this->defaultParams, $params), $options);
     }
     if (!isset($options['uri'])) {
         $uri = new HttpUri();
         if (isset($options['force_canonical']) && $options['force_canonical']) {
             if ($this->requestUri === null) {
                 throw new Exception\RuntimeException('Request URI has not been set');
             }
             $uri->setScheme($this->requestUri->getScheme())->setHost($this->requestUri->getHost())->setPort($this->requestUri->getPort());
         }
         $options['uri'] = $uri;
     } else {
         $uri = $options['uri'];
     }
     $path = $this->getBaseUrlWithLocale($options['locale']) . $route->assemble(array_merge($this->defaultParams, $params), $options);
     if (isset($options['query'])) {
         $uri->setQuery($options['query']);
     }
     if (isset($options['fragment'])) {
         $uri->setFragment($options['fragment']);
     }
     if (isset($options['force_canonical']) && $options['force_canonical'] || $uri->getHost() !== null || $uri->getScheme() !== null) {
         if (($uri->getHost() === null || $uri->getScheme() === null) && $this->requestUri === null) {
             throw new Exception\RuntimeException('Request URI has not been set');
         }
         if ($uri->getHost() === null) {
             $uri->setHost($this->requestUri->getHost());
         }
         if ($uri->getScheme() === null) {
             $uri->setScheme($this->requestUri->getScheme());
         }
         return $uri->setPath($path)->normalize()->toString();
     } elseif (!$uri->isAbsolute() && $uri->isValidRelative()) {
         return $uri->setPath($path)->normalize()->toString();
     }
     return $path;
 }