public function onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); //Cria o translator $translator = new \Zend\Mvc\I18n\Translator(new \Zend\I18n\Translator\Translator()); //Adiciona o arquivo de tradução $translator->addTranslationFile('phpArray', __DIR__ . '/../../vendor/zendframework/zend-i18n-resources/languages/pt_BR/Zend_Validate.php', 'default', 'pt_BR'); //Define o tradutor padrão dos validadores \Zend\Validator\AbstractValidator::setDefaultTranslator($translator); }
private function bootstrap($configuration) { // setup service manager $serviceManager = new ServiceManager(new ServiceManagerConfig()); $serviceManager->setService('ApplicationConfig', $configuration); // set translator $translator = new Translator(); $translator->addTranslationFilePattern('gettext', CASASYNC_PLUGIN_DIR . 'vendor/casasoft/casamodules/src/CasasoftStandards/language/', '%s.mo', 'casasoft-standards'); $translator->setLocale(substr(get_bloginfo('language'), 0, 2)); $serviceManager->setService('Translator', $translator); // mvc translator $MVCtranslator = new \Zend\Mvc\I18n\Translator($translator); $MVCtranslator->addTranslationFile('phpArray', CASASYNC_PLUGIN_DIR . 'resources/languages/' . substr(get_bloginfo('language'), 0, 2) . '/Zend_Validate.php', 'default'); \Zend\Validator\AbstractValidator::setDefaultTranslator($MVCtranslator); $this->translator = $translator; // load modules -- which will provide services, configuration, and more $serviceManager->get('ModuleManager')->loadModules(); //renderer $this->renderer = new PhpRenderer(); $pluginManager = $this->renderer->getHelperPluginManager(); //view helper plugins $defaultHelperMapClasses = ['Zend\\Form\\View\\HelperConfig', 'Zend\\I18n\\View\\HelperConfig', 'Zend\\Navigation\\View\\HelperConfig']; foreach ($defaultHelperMapClasses as $configClass) { if (is_string($configClass) && class_exists($configClass)) { $config = new $configClass(); $config->configureServiceManager($pluginManager); } } $this->serviceManager = $serviceManager; $this->queryService = $this->serviceManager->get('casawpQuery'); $this->categoryService = $this->serviceManager->get('CasasoftCategory'); $this->numvalService = $this->serviceManager->get('CasasoftNumval'); }