php Zend-Validator-AbstractValidator类(方法)实例源码

下面列出了php Zend-Validator-AbstractValidator 类(方法)源码代码实例,从而了解它的用法。

作者:schrammdocarm    项目:zf2baseap   
/**
  * 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);
 }

作者:sebaxplac    项目:skilla-loca   
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);
 }

作者:middleou    项目:mdo-bundle-zf2-local   
/**
  * @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);
 }

作者:mmatusi    项目:panel-rabate   
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);
 }

作者:oussak    项目:magasins-feedbac   
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);
     */
 }

作者:benivald    项目:zf2-na-pratic   
/**
  * 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));
 }

作者:khusamo    项目:leadin   
public function onBootstrap($e)
 {
     \Zend\Validator\AbstractValidator::setDefaultTranslator($e->getApplication()->getServiceManager()->get('translator'));
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }

作者:nouro    项目:nouro   
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));
 }

作者:juizmil    项目:ZF2-Test-Authenticatio   
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);
 }

作者:samsonasi    项目:unname   
/**
  * 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);
 }

作者:paulbrito    项目:streaming_diffusio   
/**
  * Sets validator options
  *
  * @param  string|array|\Traversable $options
  */
 public function __construct($options = null)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     $case = null;
     if (1 < func_num_args()) {
         $case = func_get_arg(1);
     }
     if (is_array($options)) {
         if (isset($options['case'])) {
             $case = $options['case'];
             unset($options['case']);
         }
         if (!array_key_exists('extension', $options)) {
             $options = array('extension' => $options);
         }
     } else {
         $options = array('extension' => $options);
     }
     if ($case !== null) {
         $options['case'] = $case;
     }
     parent::__construct($options);
 }

作者:interactive-solution    项目:zf-stdli   
/**
  * {@inheritdoc}
  */
 public function isValid($value, $data = [])
 {
     if (!is_array($value)) {
         $this->error(static::ERROR_NOT_ARRAY);
         return false;
     }
     foreach ($value as $element) {
         if (!$this->elementValidator->isValid($element, $data)) {
             $this->error(static::ERROR_NOT_ALL_VALID);
             return false;
         }
     }
     return true;
 }

作者:arstropic    项目:zf2-dashboar   
public function isValid($value)
 {
     $this->setValue($value);
     if (is_callable($this->_condition)) {
         $result = call_user_func($this->_condition);
     } else {
         $result = (bool) $this->_condition;
     }
     if ($result) {
         $valid = $this->_validator->isValid($value);
         return $valid;
     }
     return true;
 }

作者:byonche    项目:zf2-kickbo   
/**
  * Sets validator options
  *
  * @param  array|Traversable $options
  *
  * @throws InvalidArgumentException
  */
 public function __construct($options = null)
 {
     if (is_null($options)) {
         $options = [];
     }
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!array_key_exists('apiKey', $options)) {
         throw new InvalidArgumentException("Missing Kickbox API key");
     }
     if (!array_key_exists('strictMode', $options)) {
         $options['strictMode'] = false;
     }
     if (!array_key_exists('cacheAdapter', $options)) {
         $options['cacheAdapter'] = null;
     }
     if (!array_key_exists('logger', $options)) {
         $options['logger'] = null;
     }
     $this->setApiKey($options['apiKey']);
     $this->setStrictMode($options['strictMode']);
     $this->setCacheAdapter($options['cacheAdapter']);
     $this->setLogger($options['logger']);
     parent::__construct($options);
 }

作者:razvansividr    项目:pnlzf2-   
/**
  * Constructor
  *
  * @param  array|Traversable|int $options OPTIONAL
  */
 public function __construct($options = null)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         $options = func_get_args();
         $temp = array();
         if (!empty($options)) {
             $temp['type'] = array_shift($options);
         }
         $options = $temp;
     }
     if (is_array($options)) {
         if (!array_key_exists('type', $options)) {
             $detected = 0;
             $found = false;
             foreach ($options as $option) {
                 if (in_array($option, $this->constants)) {
                     $found = true;
                     $detected += array_search($option, $this->constants);
                 }
             }
             if ($found) {
                 $options['type'] = $detected;
             }
         }
     }
     parent::__construct($options);
 }

作者:totoloui    项目:ZF2-Aut   
/**
  * Sets validator options
  *
  * The array $files must be given in syntax of Zend_File_Transfer to be checked
  * If no files are given the $_FILES array will be used automatically.
  * NOTE: This validator will only work with HTTP POST uploads!
  *
  * @param  array|\Traversable $options Array of files in syntax of \Zend\File\Transfer\Transfer
  */
 public function __construct($options = array())
 {
     if (is_array($options) && !array_key_exists('files', $options)) {
         $options = array('files' => $options);
     }
     parent::__construct($options);
 }

作者:nuklehe    项目:zf   
/**
  * Constructor
  *
  * @param  array|Traversable $options
  */
 public function __construct($options = array())
 {
     parent::__construct();
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         $options = (array) $options;
     }
     foreach ($options as $key => $value) {
         switch (strtolower($key)) {
             case 'name':
                 $this->setName($value);
                 break;
             case 'salt':
                 $this->setSalt($value);
                 break;
             case 'session':
                 $this->setSession($value);
                 break;
             case 'timeout':
                 $this->setTimeout($value);
                 break;
             default:
                 // ignore unknown options
                 break;
         }
     }
 }

作者:rafalwrzeszc    项目:zf   
/**
  * Constructor
  *
  * @param array $options
  * @return \Zend\Validator\Float
  */
 public function __construct($options = null)
 {
     if (!is_array($options)) {
         $options = array('locale' => $options);
     }
     parent::__construct($options);
 }

作者:cross-solutio    项目:yawi   
public function __construct($options = null)
 {
     if ($options instanceof JobRepository) {
         $options = array('repository' => $options);
     }
     parent::__construct($options);
 }

作者:rafalwrzeszc    项目:zf   
/**
  * Sets default option values for this instance
  *
  * @param  boolean|\Zend\Config\Config $allowWhiteSpace
  * @return void
  */
 public function __construct($allowWhiteSpace = false)
 {
     parent::__construct(is_array($allowWhiteSpace) ? $allowWhiteSpace : null);
     if (is_scalar($allowWhiteSpace)) {
         $this->allowWhiteSpace = (bool) $allowWhiteSpace;
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号