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


PHP Validator\AbstractValidator类代码示例

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


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

示例1: 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

示例2: __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

示例3: 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

示例4: 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

示例5: 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

示例6: __construct

 /**
  * 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);
 }
开发者ID:paulbriton,项目名称:streaming_diffusion,代码行数:30,代码来源:Extension.php

示例7: isValid

 /**
  * {@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;
 }
开发者ID:interactive-solutions,项目名称:zf-stdlib,代码行数:17,代码来源:ArrayElementValidator.php

示例8: isValid

 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;
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:14,代码来源:Proxy.php

示例9: __construct

 /**
  * 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);
 }
开发者ID:byonchev,项目名称:zf2-kickbox,代码行数:33,代码来源:Kickbox.php

示例10: __construct

 /**
  * 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);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:35,代码来源:NotEmpty.php

示例11: __construct

 /**
  * 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);
 }
开发者ID:totolouis,项目名称:ZF2-Auth,代码行数:16,代码来源:Upload.php

示例12: __construct

 /**
  * 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;
         }
     }
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:34,代码来源:Csrf.php

示例13: __construct

 /**
  * Constructor
  *
  * @param array $options
  * @return \Zend\Validator\Float
  */
 public function __construct($options = null)
 {
     if (!is_array($options)) {
         $options = array('locale' => $options);
     }
     parent::__construct($options);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:13,代码来源:Float.php

示例14: __construct

 public function __construct($options = null)
 {
     if ($options instanceof JobRepository) {
         $options = array('repository' => $options);
     }
     parent::__construct($options);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:7,代码来源:UniqueApplyId.php

示例15: __construct

 /**
  * 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;
     }
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:13,代码来源:Alpha.php


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