/** * Checks for a collection and if needed validates the items in the collection. * This is done with the specified element validator or a validator based on * the given element type and validation group. * * Either elementValidator or elementType must be given, otherwise validation * will be skipped. * * @param mixed $value A collection to be validated * @return void * @todo: method must be protected once the old property mapper is removed */ public function isValid($value) { if (!$this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) { // @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1 if ($this->validatedInstancesContainer == NULL) { $this->validatedInstancesContainer = new \SplObjectStorage(); } if ($this->result == NULL) { $this->result = new \TYPO3\CMS\Extbase\Error\Result(); } } foreach ($value as $index => $collectionElement) { if (isset($this->options['elementValidator'])) { $collectionElementValidator = $this->validatorResolver->createValidator($this->options['elementValidator']); } elseif (isset($this->options['elementType'])) { if (isset($this->options['validationGroups'])) { $collectionElementValidator = $this->validatorResolver->getBaseValidatorConjunction($this->options['elementType'], $this->options['validationGroups']); } else { $collectionElementValidator = $this->validatorResolver->getBaseValidatorConjunction($this->options['elementType']); } } else { return; } if ($collectionElementValidator instanceof ObjectValidatorInterface) { $collectionElementValidator->setValidatedInstancesContainer($this->validatedInstancesContainer); } $this->result->forProperty($index)->merge($collectionElementValidator->validate($collectionElement)); } }
/** * Collects the base validators which were defined for the data type of each * controller argument and adds them to the argument's validator chain. * * @return void */ public function initializeControllerArgumentsBaseValidators() { foreach ($this->arguments as $argument) { $validator = $this->validatorResolver->getBaseValidatorConjunction($argument->getDataType()); if ($validator !== NULL) { $argument->setValidator($validator); } } }
/** * Collects the base validators which were defined for the data type of each * controller argument and adds them to the argument's validator chain. * * @return void */ public function initializeControllerArgumentsBaseValidators() { /** @var \TYPO3\CMS\Extbase\Mvc\Controller\Argument $argument */ foreach ($this->arguments as $argument) { $validator = $this->validatorResolver->getBaseValidatorConjunction($argument->getDataType()); if ($validator !== null) { $argument->setValidator($validator); } } }
/** * Checks for a collection and if needed validates the items in the collection. * This is done with the specified element validator or a validator based on * the given element type and validation group. * * Either elementValidator or elementType must be given, otherwise validation * will be skipped. * * @param mixed $value A collection to be validated * @return void */ protected function isValid($value) { foreach ($value as $index => $collectionElement) { if (isset($this->options['elementValidator'])) { $collectionElementValidator = $this->validatorResolver->createValidator($this->options['elementValidator']); } elseif (isset($this->options['elementType'])) { if (isset($this->options['validationGroups'])) { $collectionElementValidator = $this->validatorResolver->getBaseValidatorConjunction($this->options['elementType'], $this->options['validationGroups']); } else { $collectionElementValidator = $this->validatorResolver->getBaseValidatorConjunction($this->options['elementType']); } } else { return; } if ($collectionElementValidator instanceof ObjectValidatorInterface) { $collectionElementValidator->setValidatedInstancesContainer($this->validatedInstancesContainer); } $this->result->forProperty($index)->merge($collectionElementValidator->validate($collectionElement)); } }