當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。