Example #1
0
 /**
  * Adds the needed validators to the Arguments:
  *
  * - Validators checking the data type from the @param annotation
  * - Custom validators specified with validate annotations.
  * - Model-based validators (validate annotations in the model)
  * - Custom model validator classes
  * - Validators from framework configuration
  *
  * @return void
  */
 protected function initializeActionMethodValidators()
 {
     parent::initializeActionMethodValidators();
     $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $actionArgumentValidation = !empty($frameworkConfiguration['mvc']['validation'][$this->request->getControllerName()][$this->request->getControllerActionName()]) ? $frameworkConfiguration['mvc']['validation'][$this->request->getControllerName()][$this->request->getControllerActionName()] : array();
     // Dynamically add argument validators
     foreach ($actionArgumentValidation as $argumentName => $validators) {
         try {
             $argumentValidator = $this->arguments->getArgument($argumentName)->getValidator();
         } catch (NoSuchArgumentException $e) {
             continue;
         }
         $validatorConjunction = $this->validatorResolver->createValidator('TYPO3.CMS.Extbase:Conjunction');
         foreach ($validators as $validatorConfiguration) {
             if (isset($validatorConfiguration['type'])) {
                 $validatorType = $validatorConfiguration['type'];
                 $validatorOptions = isset($validatorConfiguration['options']) ? $validatorConfiguration['options'] : array();
                 $validator = $this->validatorResolver->createValidator($validatorType, $validatorOptions);
                 $validatorConjunction->addValidator($validator);
             }
         }
         if (count($validatorConjunction)) {
             $argumentValidator->addValidator($validatorConjunction);
         }
     }
 }
Example #2
0
 /**
  * Initialize action method validators
  *
  * @return void
  */
 protected function initializeActionMethodValidators()
 {
     if ($this->actionMethodName == 'addAction') {
         parent::initializeActionMethodValidators();
         $blog = $this->arguments['blog'];
         $validator = $blog->getValidator();
         $requestArguments = $this->request->getArguments();
         $agb = $requestArguments['data']['acceptTermsAndConditions'];
         $termsAndConditions = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Lobacher\\Simpleblog\\Validation\\Validator\\TermsAndConditionsValidator', array('value' => $agb));
         $validator->addValidator($termsAndConditions);
     } else {
         parent::initializeActionMethodValidators();
     }
 }
 /**
  * This method is overriden to allow proper assignment of parameters to fake actions.
  * 
  * Therefore we change the actionMethodName shortly if the called action is a "fake" action
  *
  * @return void
  * @see initializeArguments()
  */
 protected function initializeActionMethodValidators()
 {
     if (!is_null($this->useActionName)) {
         $temp = $this->actionMethodName;
         $this->actionMethodName = $this->useActionName;
     }
     parent::initializeActionMethodValidators();
     if (!is_null($this->useActionName)) {
         $this->actionMethodName = $temp;
     }
 }