public function createService(ServiceLocatorInterface $locator)
 {
     $config = $locator->get('config');
     $translatorConfig = array('locale' => array($config['fe_translator']['default_locale'], $config['fe_translator']['fallback_locale']), 'translation_file_patterns' => array());
     foreach ($config['fe_translator']['translations'] as $translation) {
         $translatorConfig['translation_file_patterns'][] = array('type' => 'PhpArray', 'base_dir' => $translation['base_dir'], 'pattern' => '%s.php', 'text_domain' => $translation['namespace']);
     }
     // Inject MvcEvent object
     $translator = Translator::factory($translatorConfig);
     $translator->setMyEventManager($locator->get('FeTranslator\\EventManager'));
     $translator->setMvcEvent($locator->get('Application')->getMvcEvent());
     return $translator;
 }
Ejemplo n.º 2
0
 /**
  * Generates an url given the name of a route.
  *
  * @param  string  $name               Name of the route
  * @param  array   $params             Parameters for the link
  * @param  array   $options            Options for the route
  * @param  bool    $reuseMatchedParams Whether to reuse matched parameters
  * @return string                      For the link href attribute
  */
 public function __invoke($name = null, array $params = array(), $options = array(), $reuseMatchedParams = true)
 {
     return $this->translator->translateUrl($name, null, $params, $options, false, $reuseMatchedParams);
 }