当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractValidator::setDefaultTranslator方法代码示例

本文整理汇总了PHP中Zend\Validator\AbstractValidator::setDefaultTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractValidator::setDefaultTranslator方法的具体用法?PHP AbstractValidator::setDefaultTranslator怎么用?PHP AbstractValidator::setDefaultTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Validator\AbstractValidator的用法示例。


在下文中一共展示了AbstractValidator::setDefaultTranslator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onBootstrap

 /**
  * @param MvcEvent $event
  */
 public function onBootstrap(MvcEvent $event)
 {
     $eventManager = $event->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $application = $event->getApplication();
     $eventManager = $application->getEventManager();
     /* @var $serviceManager ServiceManager */
     $serviceManager = $application->getServiceManager();
     $config = $serviceManager->get('config');
     if (array_key_exists('locale', $config)) {
         $config = $config['locale'];
     } else {
         $config = null;
     }
     if (!$config) {
         Locale::setDefault('en');
         // hardcoded here
         $translator = $serviceManager->get('translator');
         AbstractValidator::setDefaultTranslator($translator);
         return;
     }
     $settings = new Settings($config);
     // set the locale based on URL from route or cookie & set the default translator to all the app
     $eventManager->attach(MvcEvent::EVENT_ROUTE, function (MvcEvent $e) use($config, $settings, $serviceManager) {
         $settings->setRouteMatch($e->getRouteMatch());
         if (!$e->getRequest() instanceof Request) {
             $settings->setRequest($e->getRequest());
         }
         \Locale::setDefault($settings->getLocale());
         $translator = $serviceManager->get('translator');
         AbstractValidator::setDefaultTranslator($translator);
     }, -9);
 }
开发者ID:middleout,项目名称:mdo-bundle-zf2-locale,代码行数:37,代码来源:Module.php

示例2: saveAction

 /**
  * Cria ou edita um post
  * @return void
  */
 public function saveAction()
 {
     //         $translator = $this->getServiceLocator()->get('translator');
     $translator = $this->getService('translator');
     //         $cache = $this->getService('Cache');
     //         $translator->getCache($cache);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
     $form = new PostForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = new Post();
         $form->setInputFilter($post->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             unset($data['submit']);
             $data['post_date'] = date('Y-m-d H:i:s');
             $post->setData($data);
             $saved = $this->getTable('Application\\Model\\Post')->save($post);
             return $this->redirect()->toUrl('/');
         }
     }
     $id = (int) $this->params()->fromRoute('id', 0);
     if ($id > 0) {
         $post = $this->getTable('Application\\Model\\Post')->get($id);
         $form->bind($post);
         $form->get('submit')->setAttribute('value', 'Edit');
     }
     return new ViewModel(array('form' => $form));
 }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:34,代码来源:IndexController.php

示例3: onBootstrap

 public function onBootstrap($e)
 {
     \Zend\Validator\AbstractValidator::setDefaultTranslator($e->getApplication()->getServiceManager()->get('translator'));
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
开发者ID:khusamov,项目名称:leading,代码行数:7,代码来源:Module.php

示例4: onBootstrap

 public function onBootstrap($e)
 {
     \Locale::setDefault('de_DE');
     $sm = $e->getApplication()->getServiceManager();
     $translator = $sm->get('translator');
     \Zend\Validator\AbstractValidator::setDefaultTranslator(new \Zend\Mvc\I18n\Translator($translator));
 }
开发者ID:nouron,项目名称:nouron,代码行数:7,代码来源:Module.php

示例5: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
     $fallbackLocale = 'en_US';
     $sm = $e->getApplication()->getServiceManager();
     $sm->get('translator')->setLocale($locale)->setFallbackLocale($fallbackLocale);
     $type = 'phpArray';
     $pattern = './vendor/zendframework/zendframework/resources/languages/%s/Zend_Validate.php';
     $textDomain = 'default';
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     if (file_exists(sprintf($pattern, $locale))) {
         $translator->addTranslationFile($type, sprintf($pattern, $locale), $textDomain);
     } else {
         if (file_exists(sprintf($pattern, preg_replace('/_(.*)/', '', $locale)))) {
             $translator->addTranslationFile($type, sprintf($pattern, preg_replace('/_(.*)/', '', $locale)), $textDomain);
         } else {
             $pattern = sprintf($pattern, preg_replace('/_(.*)/', '', $fallbackLocale));
             $translator->addTranslationFile($type, $pattern, $textDomain);
         }
     }
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
 }
开发者ID:juizmill,项目名称:ZF2-Test-Authentication,代码行数:25,代码来源:Module.php

示例6: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     $translator->addTranslationFile('phpArray', './vendor/zendframework/zendframework/resources/languages/pl/Zend_Validate.php');
     AbstractValidator::setDefaultTranslator($translator);
     // \Zend\Debug\Debug::dump($application);
 }
开发者ID:mmatusik,项目名称:panel-rabatem,代码行数:7,代码来源:Module.php

示例7: onBootstrap

 /**
  * Bootstrap the application
  */
 public function onBootstrap(MvcEvent $e)
 {
     //Set locale
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     $translator->setLocale('en');
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
     //Define view helper routeName in view
     $e->getApplication()->getServiceManager()->get('viewhelpermanager')->setFactory('routeName', function ($sm) use($e) {
         $viewHelper = new View\Helper\RouteName($e->getRouteMatch());
         return $viewHelper;
     });
     //Define view helper UserIsLogged in view
     $e->getApplication()->getServiceManager()->get('viewhelpermanager')->setFactory('userIsLogged', function ($sm) use($e) {
         $viewHelper = new View\Helper\UserIsLogged();
         return $viewHelper;
     });
     //Handle sessions and ACL
     $this->bootstrapSession($e);
     $this->initAcl($e);
     //Attach ACL check to routeStartup
     $eventManager = $e->getApplication()->getEventManager();
     $eventManager->attach('route', array($this, 'checkAcl'));
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
开发者ID:schrammdocarmo,项目名称:zf2baseapp,代码行数:28,代码来源:Module.php

示例8: __construct

 public function __construct()
 {
     $translator = new \Zend\I18n\Translator\Translator();
     $translator->addTranslationFile('phparray', './module/Utenti/language/es.php');
     $translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
     $nombre = new Input('nome');
     $nombre->setRequired(true);
     $nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
     $nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($nombre);
     $password = new Input('password');
     $password->setRequired(true);
     $password->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
     $this->add($password);
     $confirmarPassword = new Input('confirmarPassword');
     $confirmarPassword->setRequired(true);
     $confirmarPassword->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum))->addValidator(new Identical(array('token' => 'password', 'messages' => array('notSame' => 'I dati sono errati, riprova.'))));
     $this->add($confirmarPassword);
     $imagen = new FileInput('immagine');
     $imagen->setRequired(false);
     $imagen->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/utenti/utenti_', 'use_upload_extension' => true, 'randomize' => true)));
     $imagen->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB')));
     /*
      $imagen->getValidatorChain()->attach(new MimeType(array(
      'mimeType' => 'image/png,image/x-png,image/gif,image/jpeg,image/pjpeg', 'enableHeaderCheck' => true
      )));
     */
     $this->add($imagen);
 }
开发者ID:sebaxplace,项目名称:skilla-local,代码行数:30,代码来源:RegistroValidator.php

示例9: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $sharedManager = $eventManager->getSharedManager();
     $eventManager->attach('dispatch.error', function ($event) {
         $exception = $event->getResult()->exception;
         if ($exception) {
             $sm = $event->getApplication()->getServiceManager();
             $service = $sm->get('Application\\Service\\ErrorHandling');
             $service->logException($exception);
         }
     });
     //error_reporting(E_ALL);
     $translator = new Translator();
     $translator->addTranslationFile('phpArray', 'vendor/zendframework/zendframework/resources/languages/fr/Zend_Validate.php', 'default', '*');
     $translator->addTranslationFile('phpArray', 'vendor/zendframework/zendframework/resources/languages/fr/Zend_Captcha.php', 'default', '*');
     AbstractValidator::setDefaultTranslator($translator);
     /*
     //controller can't dispatch request action that passed to the url
     $sharedManager->attach('Zend\Mvc\Controller\AbstractActionController',
         'dispatch',
         array($this, 'handleControllerCannotDispatchRequest' ), 101);
     
     //controller not found, invalid, or route is not matched anymore
     $eventManager->attach('dispatch.error',
         array($this,
             'handleControllerNotFoundAndControllerInvalidAndRouteNotFound' ), 100);
     */
 }
开发者ID:oussaka,项目名称:magasins-feedback,代码行数:31,代码来源:Module.php

示例10: setTitleAndTranslation

 /**
  * Handle layout titles onDispatch.
  *
  * @param MvcEvent $event
  */
 public function setTitleAndTranslation(MvcEvent $event)
 {
     $route = $event->getRouteMatch();
     $title = $this->service->get('ControllerPluginManager')->get('systemsettings');
     $viewHelper = $this->service->get('ViewHelperManager');
     $lang = new Container('translations');
     $translator = $this->service->get('translator');
     /*
      * Load translations.
      */
     $renderer = $this->service->get('ViewManager')->getRenderer();
     $renderer->plugin('formRow')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formCollection')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formLabel')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formSelect')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formSubmit')->setTranslator($translator, 'SD_Translations');
     AbstractValidator::setDefaultTranslator($translator, 'formandtitle');
     $translator->setLocale($lang->offsetGet('languageName'))->setFallbackLocale('en');
     $viewModel = $event->getViewModel();
     $viewModel->setVariable('lang', $translator->getLocale());
     /*
      * Custom flash messenger.
      */
     $msg = $lang->offsetGet('flashMessages');
     $viewModel->setVariable('flashMessages', $msg);
     /*
      * Load page title
      */
     $action = $route->getParam('post') ? ' - ' . $route->getParam('post') : ucfirst($route->getParam('__CONTROLLER__'));
     $headTitleHelper = $viewHelper->get('headTitle');
     $headTitleHelper->append($title->__invoke('general', 'site_name') . ' ' . $action);
 }
开发者ID:samsonasik,项目名称:unnamed,代码行数:37,代码来源:Module.php

示例11: __invoke

 public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
 {
     $translator = $callback();
     $translator->addTranslationFilePattern(PhpArray::class, Resources::getBasePath(), Resources::getPatternForValidator());
     $translator->addTranslationFilePattern(PhpArray::class, Resources::getBasePath(), Resources::getPatternForCaptcha());
     AbstractValidator::setDefaultTranslator($translator);
     return $translator;
 }
开发者ID:zetta-code,项目名称:tss-skeleton,代码行数:8,代码来源:TranslatorDelegator.php

示例12: onBootstrap

 public function onBootstrap(MvcEvent $event)
 {
     $application = $event->getApplication();
     $serviceManager = $application->getServiceManager();
     $translator = $serviceManager->get('translator');
     AbstractValidator::setDefaultTranslator($translator, 'formandtitle');
     $serviceManager->get('ViewHelperManager')->get('formcollection')->setTranslatorTextDomain('myform');
 }
开发者ID:samsonasik,项目名称:TranslationSample,代码行数:8,代码来源:Module.php

示例13: onBootstrap

 public function onBootstrap(\Zend\EventManager\EventInterface $e)
 {
     /* @var $e \Zend\Mvc\MvcEvent */
     $eventManager = $e->getApplication()->getEventManager();
     $sm = $e->getApplication()->getServiceManager();
     $translator = $sm->get('MvcTranslator');
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
 }
开发者ID:bioub,项目名称:Formation_ZF2_Adista_201602,代码行数:8,代码来源:Module.php

示例14: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $translator->addTranslationFile('phpArray', __DIR__ . '/language/de/Zend_Validate.php', 'default', 'de_DE');
     AbstractValidator::setDefaultTranslator($translator);
 }
开发者ID:darkmatus,项目名称:schwarzessachsen-core,代码行数:9,代码来源:Module.php

示例15: getCopyForm

 /**
  * @param ServiceManager $sm
  *
  * @return Form
  */
 public static function getCopyForm(ServiceManager $sm)
 {
     AbstractValidator::setDefaultTranslator($sm->get('\\VuFind\\Translator'));
     $builder = new AnnotationBuilder();
     $form = $builder->createForm('\\Swissbib\\Record\\Form\\CopyForm');
     $form->add(new Csrf('security'));
     $form->add(['name' => 'submit', 'type' => 'Submit', 'attributes' => ['value' => 'request_copy_text']]);
     return $form;
 }
开发者ID:CUSAT,项目名称:vufind,代码行数:14,代码来源:Factory.php


注:本文中的Zend\Validator\AbstractValidator::setDefaultTranslator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。