當前位置: 首頁>>代碼示例>>PHP>>正文


PHP InputFilter::isValid方法代碼示例

本文整理匯總了PHP中Zend\InputFilter\InputFilter::isValid方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputFilter::isValid方法的具體用法?PHP InputFilter::isValid怎麽用?PHP InputFilter::isValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\InputFilter\InputFilter的用法示例。


在下文中一共展示了InputFilter::isValid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: isValid

 /**
  * @param array $data
  *
  * @return bool
  */
 public function isValid($data)
 {
     if ($data === null) {
         $data = [];
     }
     $this->inputFilter->setData($data);
     return $this->inputFilter->isValid($data);
 }
開發者ID:t4web,項目名稱:crud,代碼行數:13,代碼來源:BaseValidator.php

示例2: validate

 /**
  * Validates the form data using the provided input filter.
  *
  * If validation errors are found, the form is populated with the corresponding error messages.
  * Form values are updated with the clean values provided by the filter.
  *
  * @param  Form $form
  * @return boolean
  */
 public function validate(Form $form)
 {
     $this->inputFilter->setData($form->values());
     if (!($isValid = $this->inputFilter->isValid())) {
         $form->setErrorMessages($this->inputFilter->getMessages());
         return $isValid;
     }
     $form->submit($this->inputFilter->getValues());
     return $isValid;
 }
開發者ID:comphppuebla,項目名稱:easy-forms,代碼行數:19,代碼來源:InputFilterValidator.php

示例3: onDispatch

 /**
  * @param MvcEvent $e
  * @return mixed|void
  */
 public function onDispatch(MvcEvent $e)
 {
     $this->inputFilter->setData($this->params()->fromPost());
     if (!$this->inputFilter->isValid()) {
         $this->flashMessenger()->addErrorMessage($this->inputFilter->getMessages());
         return $this->redirect()->toRoute('frontend');
     }
     try {
         $this->pagesResource->download($this->inputFilter->getValue('site_url'));
         $this->flashMessenger()->addSuccessMessage('Url successfully queued for download all images');
     } catch (ApiException $e) {
         $this->flashMessenger()->addErrorMessage($e->getMessage());
     }
     $this->redirect()->toRoute('frontend');
 }
開發者ID:spalax,項目名稱:eu-webchalange-download-images-api,代碼行數:19,代碼來源:AddController.php

示例4: isValid

 public function isValid()
 {
     if (!is_null($this->isValid)) {
         return $this->isValid;
     }
     return $this->isValid = parent::isValid();
 }
開發者ID:spalax,項目名稱:zf2-libs,代碼行數:7,代碼來源:AbstractInputFilter.php

示例5: isValid

 /**
  * Override isValid to provide conditional input checking
  * @return bool
  */
 public function isValid()
 {
     if (!$this->isValidService()) {
         return false;
     }
     return parent::isValid();
 }
開發者ID:zfcampus,項目名稱:zf-apigility-admin,代碼行數:11,代碼來源:PostInputFilter.php

示例6: uploadImageAction

 public function uploadImageAction()
 {
     $this->checkAuth();
     $request = $this->getRequest();
     if ($request->isPost()) {
         // File upload input
         $file = new FileInput('avatar');
         // Special File Input type
         $file->getValidatorChain()->attach(new Validator\File\UploadFile());
         $file->getFilterChain()->attach(new Filter\File\RenameUpload(array('target' => './public/files/users/avatar/origin/', 'use_upload_name' => true, 'randomize' => true)));
         // Merge $_POST and $_FILES data together
         $request = new Request();
         $postData = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $inputFilter = new InputFilter();
         $inputFilter->add($file)->setData($postData);
         if ($inputFilter->isValid()) {
             // FileInput validators are run, but not the filters...
             $data = $inputFilter->getValues();
             // This is when the FileInput filters are run.
             $avatar = basename($data['avatar']['tmp_name']);
             $this->databaseService->updateAvatar($this->user->id, $avatar);
             $this->user->avatar = $avatar;
         } else {
             // error
         }
     }
     return $this->redirect()->toRoute('profile');
 }
開發者ID:kienbk1910,項目名稱:RDCAdmin,代碼行數:28,代碼來源:ProfileController.php

示例7: process

 /**
  * Perform any processing or data manipulation needed before render.
  *
  * A response helper object will be passed to this method to allow you to
  * easily add success messages or redirects.  This helper should be used
  * to handle these kinds of actions so that you can easily test your
  * page's code.
  *
  * @param ResponseHelper $responseHelper
  * @return ResponseHelper|null
  */
 public function process(ResponseHelper $responseHelper)
 {
     $isCurrentUser = $this->row->get('user_id') === Pimple::getResource('user')->get('user_id');
     if (!$this->component->getPermissions()->can('edit') && !$isCurrentUser) {
         return $responseHelper->redirectToUrl('/admin');
     }
     if ($this->request->isPost()) {
         $this->inputFilter->setData($this->request->getPost());
         if ($this->inputFilter->isValid()) {
             $this->row->hashPassword($this->request->getPost('password'))->save();
             if ($isCurrentUser) {
                 return $responseHelper->redirectToUrl('/admin');
             } else {
                 return $responseHelper->redirectToAdminPage('index');
             }
         }
     }
 }
開發者ID:deltasystems,項目名稱:dewdrop,代碼行數:29,代碼來源:ChangePassword.php

示例8: isValid

 public function isValid()
 {
     $fields = ['id', 'mode'];
     $mode = $this->getMode();
     if ($mode == 'timecreated') {
         $fields[] = 'timecreated';
     }
     $this->setValidationGroup($fields);
     return parent::isValid();
 }
開發者ID:arstropica,項目名稱:zf2-dashboard,代碼行數:10,代碼來源:DateFilterFieldsetInputFilter.php

示例9: isValid

 public function isValid()
 {
     $type = $this->getType();
     if ($type) {
         $field = $this->_getRelationshipInput($type);
         if ($field) {
             $this->setValidationGroup(['id', 'type', $field]);
         }
     }
     return parent::isValid();
 }
開發者ID:arstropica,項目名稱:zf2-dashboard,代碼行數:11,代碼來源:ValueFieldsetInputFilter.php

示例10: isValid

 /**
  * {@inheritDoc}
  */
 public function isValid($context = null)
 {
     $valid = parent::isValid($context);
     if (!$valid) {
         return $valid;
     }
     $validators = $this->getValidatorChain();
     $valid = $validators->isValid(new \ArrayObject($this->getValues()), $context);
     if (!$valid) {
         $validators->getMessages();
     }
     return $valid;
 }
開發者ID:coolms,項目名稱:common,代碼行數:16,代碼來源:InputFilter.php

示例11: __invoke

 /**
  * __invoke
  *
  * @param Request       $request
  * @param Response      $response
  * @param callable|null $out
  *
  * @return mixed
  */
 public function __invoke(Request $request, Response $response, callable $out = null)
 {
     $filterConfig = $this->getOption($request, 'config', []);
     $inputFilter = new InputFilter();
     $factory = $inputFilter->getFactory();
     foreach ($filterConfig as $field => $config) {
         $inputFilter->add($factory->createInput($config));
     }
     $dataModel = $request->getParsedBody();
     $inputFilter->setData($dataModel);
     if ($inputFilter->isValid()) {
         return $out($request, $response);
     }
     $messages = new ZfInputFilterMessageResponseModels($inputFilter, $this->getOption($request, 'primaryMessage', 'An Error Occurred'), $this->getOption($request, 'messageParams', []));
     return $this->getResponseWithDataBody($response, $messages);
 }
開發者ID:reliv,項目名稱:pipe-rat,代碼行數:25,代碼來源:ZfInputFilterConfig.php

示例12: isValid

 public function isValid()
 {
     $valid = parent::isValid();
     if ($this->checkPassword) {
         $password = $this->get('password');
         $confirm_password = $this->get('confirm_password');
         if ($password->getValue() != $confirm_password->getValue()) {
             $valid = false;
             $password->setErrorMessage('Passwords did not match');
             if (!isset($this->invalidInputs[$password->getName()])) {
                 $this->invalidInputs[$password->getName()] = $password;
             }
             $confirm_password->setErrorMessage('Passwords did not match');
             if (!isset($this->invalidInputs[$confirm_password->getName()])) {
                 $this->invalidInputs[$confirm_password->getName()] = $confirm_password;
             }
         }
     }
     return $valid;
 }
開發者ID:shashidharg,項目名稱:CommunicationApp,代碼行數:20,代碼來源:UsersFilter.php

示例13: isValid

 /**
  * Check if login form is valid
  *  - first call parent to validate fields
  *  - get user by identity and validate
  * @return bool
  */
 public function isValid()
 {
     $valid = parent::isValid();
     if ($valid) {
         $identity = $this->get('identity')->getValue();
         $credential = $this->get('credential')->getValue();
         $user = $this->getUserByIdentity($identity);
         if (!$user) {
             $this->invalidInputs['identity'] = $this->get('identity');
             $this->get('identity')->setErrorMessage('Invalid identity or credential supplied.');
             return false;
         }
         $salt = $user->getPasswordSalt();
         $password = $user->getPassword();
         if (!$this->_isValidCredential($password, $salt, $credential)) {
             $this->invalidInputs['identity'] = $this->get('identity');
             $this->get('identity')->setErrorMessage('Invalid identity or credential supplied.');
             return false;
         }
     }
     return $valid;
 }
開發者ID:Ellipizle,項目名稱:dotscms,代碼行數:28,代碼來源:LoginInputFilter.php

示例14: isValid

 public function isValid($context = null)
 {
     $data = $this->data;
     if (null === $data) {
         return parent::isValid($context);
     }
     if ($data instanceof Traversable) {
         $data = iterator_to_array($data);
     }
     if (is_object($data)) {
         $data = (array) $data;
     }
     if (!isset($data['dsn'])) {
         $data['dsn'] = null;
     }
     if (isset($data['dsn_type']) && 'Mongo' === $data['dsn_type']) {
         if (!isset($data['database'])) {
             $data['database'] = null;
         }
     }
     $this->setData($data);
     return parent::isValid($context);
 }
開發者ID:zfcampus,項目名稱:zf-apigility-admin,代碼行數:23,代碼來源:OAuth2InputFilter.php

示例15: isValid

 /**
  * Is the data set valid?
  *
  * @throws RuntimeException
  * @return bool
  */
 public function isValid()
 {
     if (true === ($valid = parent::isValid())) {
         $validator = new Callback(array('callback' => function ($values) {
             if (isset($values['query']) || isset($values['latitude']) && isset($values['longitude']) || isset($values['id'])) {
                 return true;
             }
         }, 'messages' => array(Callback::INVALID_VALUE => 'Requires a query, id, or latitude and longitude')));
         if (true === ($valid = $validator->isValid($this->getValues()))) {
             $this->validInputs['atLeastOne'] = $validator;
         } else {
             $this->invalidInputs['atLeastOne'] = $validator;
         }
     }
     return $valid;
 }
開發者ID:monkeyphp,項目名稱:open-weather-map,代碼行數:22,代碼來源:ParameterFilter.php


注:本文中的Zend\InputFilter\InputFilter::isValid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。