diff --git a/typo3/sysext/extbase/Classes/Error/Result.php b/typo3/sysext/extbase/Classes/Error/Result.php index b03a735a397640eebe6188b57185ce3ffbecc88e..02cfdb50e2307bb4bcb724857d6615e4748a2a10 100644 --- a/typo3/sysext/extbase/Classes/Error/Result.php +++ b/typo3/sysext/extbase/Classes/Error/Result.php @@ -33,16 +33,34 @@ class Result { */ protected $errors = array(); + /** + * Caches the existence of errors + * @var boolean + */ + protected $errorsExist = FALSE; + /** * @var array<\TYPO3\CMS\Extbase\Error\Warning> */ protected $warnings = array(); + /** + * Caches the existence of warning + * @var boolean + */ + protected $warningsExist = FALSE; + /** * @var array<\TYPO3\CMS\Extbase\Error\Notice> */ protected $notices = array(); + /** + * Caches the existence of notices + * @var boolean + */ + protected $noticesExist = FALSE; + /** * The result objects for the sub properties * @@ -50,6 +68,33 @@ class Result { */ protected $propertyResults = array(); + /** + * @var \TYPO3\CMS\Extbase\Error\Result + */ + protected $parent = NULL; + + /** + * Injects the parent result and propagates the + * cached error states upwards + * + * @param \TYPO3\CMS\Extbase\Error\Error $parent + * @return void + */ + public function setParent(Result $parent) { + if ($this->parent !== $parent) { + $this->parent = $parent; + if ($this->hasErrors()) { + $parent->setErrorsExist(); + } + if ($this->hasWarnings()) { + $parent->setWarningsExist(); + } + if ($this->hasNotices()) { + $parent->setNoticesExist(); + } + } + } + /** * Add an error to the current Result object * @@ -59,6 +104,7 @@ class Result { */ public function addError(\TYPO3\CMS\Extbase\Error\Error $error) { $this->errors[] = $error; + $this->setErrorsExist(); } /** @@ -70,6 +116,7 @@ class Result { */ public function addWarning(\TYPO3\CMS\Extbase\Error\Warning $warning) { $this->warnings[] = $warning; + $this->setWarningsExist(); } /** @@ -81,6 +128,7 @@ class Result { */ public function addNotice(\TYPO3\CMS\Extbase\Error\Notice $notice) { $this->notices[] = $notice; + $this->setNoticesExist(); } /** @@ -174,13 +222,81 @@ class Result { if (count($pathSegments) === 0) { return $this; } + $propertyName = array_shift($pathSegments); + if (!isset($this->propertyResults[$propertyName])) { - $this->propertyResults[$propertyName] = new \TYPO3\CMS\Extbase\Error\Result(); + $this->propertyResults[$propertyName] = new Result(); } + return $this->propertyResults[$propertyName]->recurseThroughResult($pathSegments); } + /** + * Sets the error cache to TRUE and propagates the information + * upwards the Result-Object Tree + * + * @return void + */ + protected function setErrorsExist() { + $this->errorsExist = TRUE; + if ($this->parent !== NULL) { + $this->parent->setErrorsExist(); + } + } + + /** + * Sets the warning cache to TRUE and propagates the information + * upwards the Result-Object Tree + * + * @return void + */ + protected function setWarningsExist() { + $this->warningsExist = TRUE; + if ($this->parent !== NULL) { + $this->parent->setWarningsExist(); + } + } + + /** + * Sets the notices cache to TRUE and propagates the information + * upwards the Result-Object Tree + * + * @return void + */ + protected function setNoticesExist() { + $this->noticesExist = TRUE; + if ($this->parent !== NULL) { + $this->parent->setNoticesExist(); + } + } + + /** + * Does the current Result object have Notices, Errors or Warnings? (Recursively) + * + * @return boolean + */ + public function hasMessages() { + return $this->errorsExist || $this->noticesExist || $this->warningsExist; + } + + /** + * Clears the result + * + * @return void + */ + public function clear() { + $this->errors = array(); + $this->notices = array(); + $this->warnings = array(); + + $this->warningsExist = FALSE; + $this->noticesExist = FALSE; + $this->errorsExist = FALSE; + + $this->propertyResults = array(); + } + /** * Internal use only! * @@ -232,7 +348,7 @@ class Result { /** * Get a list of all Error objects recursively. The result is an array, - * where the key is the property path where the error occured, and the + * where the key is the property path where the error occurred, and the * value is a list of all errors (stored as array) * * @return array<\TYPO3\CMS\Extbase\Error\Error> @@ -260,7 +376,7 @@ class Result { /** * Get a list of all Notice objects recursively. The result is an array, - * where the key is the property path where the notice occured, and the + * where the key is the property path where the notice occurred, and the * value is a list of all notices (stored as array) * * @return array<\TYPO3\CMS\Extbase\Error\Notice> @@ -278,13 +394,13 @@ class Result { * Flatten a tree of Result objects, based on a certain property. * * @param string $propertyName - * @param array &$result + * @param array $result * @param array $level * @return void */ public function flattenTree($propertyName, &$result, $level) { - if (count($this->{$propertyName}) > 0) { - $result[implode('.', $level)] = $this->{$propertyName}; + if (count($this->$propertyName) > 0) { + $result[implode('.', $level)] = $this->$propertyName; } foreach ($this->propertyResults as $subPropertyName => $subResult) { array_push($level, $subPropertyName); @@ -317,9 +433,9 @@ class Result { * @param string $adderName * @return void */ - protected function mergeProperty(\TYPO3\CMS\Extbase\Error\Result $otherResult, $getterName, $adderName) { - foreach ($otherResult->{$getterName}() as $messageInOtherResult) { - $this->{$adderName}($messageInOtherResult); + protected function mergeProperty(Result $otherResult, $getterName, $adderName) { + foreach ($otherResult->$getterName() as $messageInOtherResult) { + $this->$adderName($messageInOtherResult); } } diff --git a/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php b/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php index e7da4e5c189fc209490aca704a1e473aca3e4a8f..5c659a3a9548483c431f287e70d421d21a548488 100644 --- a/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php +++ b/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php @@ -549,6 +549,28 @@ class ActionController extends \TYPO3\CMS\Extbase\Mvc\Controller\AbstractControl } } } + + /** + * Returns a map of action method names and their parameters. + * + * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager + * @return array Array of method parameters by action name + */ + static public function getActionMethodParameters($objectManager) { + $reflectionService = $objectManager->get('TYPO3\CMS\Extbase\Reflection\ReflectionService'); + + $result = array(); + + $className = get_called_class(); + $methodNames = get_class_methods($className); + foreach ($methodNames as $methodName) { + if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== FALSE) { + $result[$methodName] = $reflectionService->getMethodParameters($className, $methodName); + } + } + + return $result; + } } -?> \ No newline at end of file +?> diff --git a/typo3/sysext/extbase/Classes/Validation/Error.php b/typo3/sysext/extbase/Classes/Validation/Error.php index c2fddd1f03d6d2683f593d458b012f6aa08e75d5..7a3c6016ca7784413cb07eda0a8c44db957e4d28 100644 --- a/typo3/sysext/extbase/Classes/Validation/Error.php +++ b/typo3/sysext/extbase/Classes/Validation/Error.php @@ -27,19 +27,20 @@ namespace TYPO3\CMS\Extbase\Validation; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Objects of this kind contain a list of validation errors which occurred during - * validation. + * This object holds a validation error. + * */ class Error extends \TYPO3\CMS\Extbase\Error\Error { /** - * @var string The default (english) error message. + * @var string */ protected $message = 'Unknown validation error'; /** - * @var string The error code + * @var string */ protected $code = 1201447005; } diff --git a/typo3/sysext/extbase/Classes/Validation/Exception.php b/typo3/sysext/extbase/Classes/Validation/Exception.php index 83b755fe32487290451cd8c537303ca3f9d65a06..0518d7110e3a14447dac2c23bb97e66f64bc1b3d 100644 --- a/typo3/sysext/extbase/Classes/Validation/Exception.php +++ b/typo3/sysext/extbase/Classes/Validation/Exception.php @@ -27,8 +27,11 @@ namespace TYPO3\CMS\Extbase\Validation; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** * A generic validation exception + * + * @api */ class Exception extends \TYPO3\CMS\Extbase\Exception { diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/AbstractCompositeValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/AbstractCompositeValidator.php index fc985784dc1a15973801afe30e2ca48dbb41d2b2..c7879a3390ef0fbb860e757bbd0e052bfa10ebaa 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/AbstractCompositeValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/AbstractCompositeValidator.php @@ -34,6 +34,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; */ abstract class AbstractCompositeValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface, \Countable { + /** + * This contains the supported options, their default values and descriptions. + * + * @var array + */ + protected $supportedOptions = array(); + /** * @var array */ @@ -44,13 +51,20 @@ abstract class AbstractCompositeValidator implements \TYPO3\CMS\Extbase\Validati */ protected $validators; + /** + * @var \SplObjectStorage + */ + protected $validatedInstancesContainer; + /** * @var array */ protected $errors = array(); /** - * Constructs the validator conjunction + * Constructs the composite validator and sets validation options + * + * @api */ public function __construct() { $this->validators = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); @@ -81,6 +95,7 @@ abstract class AbstractCompositeValidator implements \TYPO3\CMS\Extbase\Validati * * @param \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface $validator The validator that should be added * @return void + * @api */ public function addValidator(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface $validator) { $this->validators->attach($validator); @@ -104,10 +119,40 @@ abstract class AbstractCompositeValidator implements \TYPO3\CMS\Extbase\Validati * Returns the number of validators contained in this conjunction. * * @return integer The number of validators + * @api */ public function count() { return count($this->validators); } + + /** + * Returns the child validators of this Composite Validator + * + * @return \SplObjectStorage + */ + public function getValidators() { + return $this->validators; + } + + /** + * Returns the options for this validator + * + * @return array + */ + public function getOptions() { + return $this->options; + } + + /** + * Allows to set a container to keep track of validated instances. + * + * @param \SplObjectStorage $validatedInstancesContainer A container to keep track of validated instances + * @return void + * @api + */ + public function setValidatedInstancesContainer(\SplObjectStorage $validatedInstancesContainer) { + $this->validatedInstancesContainer = $validatedInstancesContainer; + } } ?> \ No newline at end of file diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/AbstractValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/AbstractValidator.php index b2992f8c17af37ce1e049a89ca8ebbfa4e9ab02e..93ac1d8c9e8e605c8ab53612c5d0ad604e9b39b0 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/AbstractValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/AbstractValidator.php @@ -32,6 +32,24 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; */ abstract class AbstractValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface { + /** + * Specifies whether this validator accepts empty values. + * + * If this is TRUE, the validators isValid() method is not called in case of an empty value + * Note: A value is considered empty if it is NULL or an empty string! + * By default all validators except for NotEmpty and the Composite Validators accept empty values + * + * @var boolean + */ + protected $acceptsEmptyValues = TRUE; + + /** + * This contains the supported options, their default values, types and descriptions. + * + * @var array + */ + protected $supportedOptions = array(); + /** * @var array */ @@ -119,6 +137,23 @@ abstract class AbstractValidator implements \TYPO3\CMS\Extbase\Validation\Valida // the following is @deprecated since Extbase 1.4.0: $this->errors[] = new \TYPO3\CMS\Extbase\Validation\Error($message, $code, $arguments, $title); } + + /** + * Returns the options of this validator + * + * @return array + */ + public function getOptions() { + return $this->options; + } + + /** + * @param mixed $value + * @return boolean TRUE if the given $value is NULL or an empty string ('') + */ + final protected function isEmpty($value) { + return $value === NULL || $value === ''; + } } ?> \ No newline at end of file diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/AlphanumericValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/AlphanumericValidator.php index 163584000a4cb5954a908aeabf21d43132abc834..7cb6d8e18786543771aeeb256b59dfb27812df88 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/AlphanumericValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/AlphanumericValidator.php @@ -29,8 +29,10 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; ***************************************************************/ /** * Validator for alphanumeric strings + * + * @api */ -class AlphanumericValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class AlphanumericValidator extends AbstractValidator { /** * Returns TRUE, if the given property ($propertyValue) is a valid diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/ConjunctionValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/ConjunctionValidator.php index 6f8e531f9887df8cdf983f07e7c762b4e014097d..226381ce171f122179f5754a71469dee2710592b 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/ConjunctionValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/ConjunctionValidator.php @@ -27,13 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator to chain many validators in a conjunction (logical and). So every - * validator has to be valid, to make the whole conjunction valid. + * Validator to chain many validators in a conjunction (logical and). * - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later + * @api */ -class ConjunctionValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractCompositeValidator { +class ConjunctionValidator extends AbstractCompositeValidator { /** * Checks if the given value is valid according to the validators of the conjunction. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/DateTimeValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/DateTimeValidator.php index 252bdf602505f696a5186c7c5222c7caac0c8207..a003b36a3103c65614a832a31370508b9ba5bbb9 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/DateTimeValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/DateTimeValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for DateTime objects + * Validator for DateTime objects. + * + * @api */ -class DateTimeValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class DateTimeValidator extends AbstractValidator { /** * Checks if the given value is a valid DateTime object. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/DisjunctionValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/DisjunctionValidator.php index 7cb2327b295e08ee8cb43701b2ac137fe403b3a1..24e66993f9fd433670fa782100ebbb65c412f493 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/DisjunctionValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/DisjunctionValidator.php @@ -27,14 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator to chain many validators in a disjunction (logical or). So only one - * validator has to be valid, to make the whole disjunction valid. Errors are - * only returned if all validators failed. + * Validator to chain many validators in a disjunction (logical or). * - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later + * @api */ -class DisjunctionValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractCompositeValidator { +class DisjunctionValidator extends AbstractCompositeValidator { /** * Checks if the given value is valid according to the validators of the diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/EmailAddressValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/EmailAddressValidator.php index 2a66d5ec06039abdf658d8e2f5d6e7f4ca2e29d3..d8cd99b4ca77a71d0c43599ac97cdeef944274cf 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/EmailAddressValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/EmailAddressValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** * Validator for email addresses + * + * @api */ -class EmailAddressValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class EmailAddressValidator extends AbstractValidator { /** * Checks if the given value is a valid email address. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/FloatValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/FloatValidator.php index 7c15b33b0f4871485a609e2890eaf8d95f715969..a61d7bfb6229a30e59f288c35b7892451cfdb6a6 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/FloatValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/FloatValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for floats + * Validator for floats. + * + * @api */ -class FloatValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class FloatValidator extends AbstractValidator { /** * Checks if the given value is a valid float. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/IntegerValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/IntegerValidator.php index 69eb98c81131f664d1a643b727fd3b5350d5f147..7b7120acf303fd1d6953b8f5d1ab352f76b56966 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/IntegerValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/IntegerValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for integers + * Validator for integers. + * + * @api */ -class IntegerValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class IntegerValidator extends AbstractValidator { /** * Checks if the given value is a valid integer. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/NotEmptyValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/NotEmptyValidator.php index 4759a28dd66b40a85057cd84cf318e0c9e46e8bb..97ad0232c574109493de752946a56a6033a00b83 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/NotEmptyValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/NotEmptyValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for not empty values + * Validator for not empty values. + * + * @api */ -class NotEmptyValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class NotEmptyValidator extends AbstractValidator { /** * Checks if the given property ($propertyValue) is not empty (NULL, empty string, empty array or empty object). diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/NumberRangeValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/NumberRangeValidator.php index 83b0691d6ecafa87523ae2acad72b8d79ef26e33..06f39be1879ae7c0cb437d57dfca00eb5251db6d 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/NumberRangeValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/NumberRangeValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** * Validator for general numbers + * + * @api */ -class NumberRangeValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class NumberRangeValidator extends AbstractValidator { /** * Returns TRUE, if the given property ($propertyValue) is a valid number in the given range. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/NumberValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/NumberValidator.php index 309c2bd1bbcee38561fa95637d5b8585b357d30e..44bda860e892ed3fcf44c7c4f1e68026e3aaa257 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/NumberValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/NumberValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for general numbers + * Validator for general numbers. + * + * @api */ -class NumberValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class NumberValidator extends AbstractValidator { /** * Checks if the given value is a valid number. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/ObjectValidatorInterface.php b/typo3/sysext/extbase/Classes/Validation/Validator/ObjectValidatorInterface.php index c94f996b3937e8c8e138e00003e44341d419913b..fe4ca7be8b4e0f46e9048655d64a4ed2fb327bd9 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/ObjectValidatorInterface.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/ObjectValidatorInterface.php @@ -28,17 +28,19 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** - * Contract for an object validator + * Contract for a validator * - * @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1 + * @api */ -interface ObjectValidatorInterface extends \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface { +interface ObjectValidatorInterface extends ValidatorInterface { /** * Checks the given object can be validated by the validator implementation * * @param object $object The object to be checked * @return boolean TRUE if this validator can validate instances of the given object or FALSE if it can't + * + * @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1 */ public function canValidate($object); @@ -50,6 +52,8 @@ interface ObjectValidatorInterface extends \TYPO3\CMS\Extbase\Validation\Validat * @param object $object The object containing the property to validate * @param string $propertyName Name of the property to validate * @return boolean TRUE if the property value is valid, FALSE if an error occured + * + * @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1 */ public function isPropertyValid($object, $propertyName); } diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/RawValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/RawValidator.php index f794c4f77ec8759cc14e446424e5fd8f26e62876..3304c373d6720db22be8bbf01ab49474f190ef32 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/RawValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/RawValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * A validator which accepts any input + * A validator which accepts any input. + * + * @api */ -class RawValidator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface { +class RawValidator implements ValidatorInterface { /** * Always returns TRUE diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/RegularExpressionValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/RegularExpressionValidator.php index 03b03345b5c51628d40831a7b4a9aac664c55498..110b76eb99366ece20b8ad2c0d52502940e7f41e 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/RegularExpressionValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/RegularExpressionValidator.php @@ -27,12 +27,14 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator based on regular expressions + * Validator based on regular expressions. * - * The regular expression is specified in the options by using the array key "regularExpression" + * @api */ -class RegularExpressionValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class RegularExpressionValidator extends AbstractValidator { + /** * Returns TRUE, if the given property ($value) matches the given regular expression. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/StringLengthValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/StringLengthValidator.php index f28cda62f928b2422d3a7daf1f1fb52e770f23f6..184ac38f0689601378eb26c9e34d8389f6373fc0 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/StringLengthValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/StringLengthValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for string length + * Validator for string length. + * + * @api */ -class StringLengthValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class StringLengthValidator extends AbstractValidator { /** * Returns TRUE, if the given property ($value) is a valid string and its length diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php index 43a46b8b76fa8b896d6433c2c9bcad05b4007dcd..ae9b70a25e257a8fc832ac05557e94b408baab39 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for string length + * Validator for strings. + * + * @api */ -class StringValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class StringValidator extends AbstractValidator { /** * Returns TRUE, if the given property ($value) is a valid string. diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TextValidator.php b/typo3/sysext/extbase/Classes/Validation/Validator/TextValidator.php index 39554de29d6f8d02f1d6659de3a10105fea6b887..20e9de5ab0d01f7a8d2218ad964f0e07b5e4c1cc 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/TextValidator.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/TextValidator.php @@ -27,10 +27,13 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + /** - * Validator for text + * Validator for "plain" text. + * + * @api */ -class TextValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator { +class TextValidator extends AbstractValidator { /** * Returns TRUE, if the given property ($propertyValue) is a valid text (contains no XML tags). diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/ValidatorInterface.php b/typo3/sysext/extbase/Classes/Validation/Validator/ValidatorInterface.php index 07244b85d0111b9dbcb10f84a085e5a409b9f8e1..ceec3b681dc61419b5f0a5bb03cfbcc301188b61 100644 --- a/typo3/sysext/extbase/Classes/Validation/Validator/ValidatorInterface.php +++ b/typo3/sysext/extbase/Classes/Validation/Validator/ValidatorInterface.php @@ -28,18 +28,7 @@ namespace TYPO3\CMS\Extbase\Validation\Validator; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** - * Contract for a validator. This interface has drastically changed with Extbase 1.4.0, so that's why this interface does not contain any mandatory methods. - * - * For compatibility with Extbase < 1.4.0, the following methods need to exist: - * - setOptions($options) to set validation options - * - isValid($object) to check whether an object is valid (returns boolean value) - * - getErrors() to get errors occuring during validation. - * - * For Extbase >= 1.4.0, the following methods need to exist: - * - __construct($options) to set validation options - * - validate($object) to check whether the given object is valid. Returns a \TYPO3\CMS\Extbase\Error\Result object which can then be checked for validity. - * - * Please see the source file for proper documentation of the above methods. + * Contract for a validator * * @api */ diff --git a/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php b/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php index cf03addecc696579106548ad8b27aa09ab364c97..f350c44859ece02d20023e2be468f4ebd9f279cd 100644 --- a/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php +++ b/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php @@ -39,35 +39,35 @@ class ValidatorResolver implements \TYPO3\CMS\Core\SingletonInterface { /** * Match validator names and options + * @todo: adjust [a-z0-9_:.\\\\] once Tx_Extbase_Foo syntax is outdated. * * @var string */ const PATTERN_MATCH_VALIDATORS = '/ - (?:^|,\\s*) + (?:^|,\s*) (?P<validatorName>[a-z0-9_:.\\\\]+) - \\s* - (?:\\( - (?P<validatorOptions>(?:\\s*[a-z0-9]+\\s*=\\s*(?: + \s* + (?:\( + (?P<validatorOptions>(?:\s*[a-z0-9]+\s*=\s*(?: "(?:\\\\"|[^"])*" |\'(?:\\\\\'|[^\'])*\' - |(?:\\s|[^,"\']*) - )(?:\\s|,)*)*) - \\))? + |(?:\s|[^,"\']*) + )(?:\s|,)*)*) + \))? /ixS'; /** * Match validator options (to parse actual options) - * * @var string */ const PATTERN_MATCH_VALIDATOROPTIONS = '/ - \\s* + \s* (?P<optionName>[a-z0-9]+) - \\s*=\\s* + \s*=\s* (?P<optionValue> "(?:\\\\"|[^"])*" |\'(?:\\\\\'|[^\'])*\' - |(?:\\s|[^,"\']*) + |(?:\s|[^,"\']*) ) /ixS'; @@ -354,7 +354,7 @@ class ValidatorResolver implements \TYPO3\CMS\Core\SingletonInterface { /** * Shorthand built in */ - $possibleClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\' . $this->unifyDataType($validatorName); + $possibleClassName = 'TYPO3\\CMS\\Extbase\\Validation\\Validator\\' . $this->getValidatorType($validatorName); } } else { /** @@ -383,12 +383,12 @@ class ValidatorResolver implements \TYPO3\CMS\Core\SingletonInterface { } /** - * Preprocess data types. Used to map primitive PHP types to DataTypes used in Extbase. + * Used to map PHP types to validator types. * * @param string $type Data type to unify * @return string unified data type */ - protected function unifyDataType($type) { + protected function getValidatorType($type) { switch ($type) { case 'int': $type = 'Integer'; diff --git a/typo3/sysext/extbase/Tests/Unit/Error/ResultTest.php b/typo3/sysext/extbase/Tests/Unit/Error/ResultTest.php index 71708866d1d581778b0200c8edf08268251259c3..c899961768ee9436d696187543b6d964b121f98e 100644 --- a/typo3/sysext/extbase/Tests/Unit/Error/ResultTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Error/ResultTest.php @@ -152,7 +152,7 @@ class ResultTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { * @param string $dataTypeInSingular * @param string $dataTypeInPlural */ - public function hasMessageshouldReturnTrueIfSubObjectHasErrors($dataTypeInSingular, $dataTypeInPlural) { + public function hasMessagesShouldReturnTrueIfSubObjectHasErrors($dataTypeInSingular, $dataTypeInPlural) { $addMethodName = 'add' . $dataTypeInSingular; $methodName = 'has' . $dataTypeInPlural; $message = $this->getMockMessage($dataTypeInSingular); diff --git a/typo3/sysext/extbase/Tests/Unit/Validation/ValidatorResolverTest.php b/typo3/sysext/extbase/Tests/Unit/Validation/ValidatorResolverTest.php index f82c2244eae7601d768b48fa4d3746d3425546a0..f06c1e777b5729e1da881a47cacbde33c81534b5 100644 --- a/typo3/sysext/extbase/Tests/Unit/Validation/ValidatorResolverTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Validation/ValidatorResolverTest.php @@ -377,11 +377,11 @@ class ValidatorResolverTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { * @test * @author Bastian Waidelich <bastian@typo3.org> */ - public function resolveValidatorObjectNameCallsUnifyDataType() { + public function resolveValidatorObjectNameCallsGetValidatorType() { $validatorName = uniqid('FooValidator'); eval('namespace TYPO3\CMS\Extbase\Validation\Validator;' . LF . 'class ' . $validatorName . 'Validator implements \TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface {}'); - $mockValidatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('unifyDataType')); - $mockValidatorResolver->expects($this->once())->method('unifyDataType')->with($validatorName)->will($this->returnValue($validatorName)); + $mockValidatorResolver = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array('getValidatorType')); + $mockValidatorResolver->expects($this->once())->method('getValidatorType')->with($validatorName)->will($this->returnValue($validatorName)); $mockValidatorResolver->_call('resolveValidatorObjectName', $validatorName); } @@ -390,26 +390,26 @@ class ValidatorResolverTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { * @test * @author Bastian Waidelich <bastian@typo3.org> */ - public function unifyDataTypeCorrectlyRenamesPhpDataTypes() { - $this->assertEquals('Integer', $this->validatorResolver->_call('unifyDataType', 'integer')); - $this->assertEquals('Integer', $this->validatorResolver->_call('unifyDataType', 'int')); - $this->assertEquals('String', $this->validatorResolver->_call('unifyDataType', 'string')); - $this->assertEquals('Array', $this->validatorResolver->_call('unifyDataType', 'array')); - $this->assertEquals('Float', $this->validatorResolver->_call('unifyDataType', 'float')); - $this->assertEquals('Float', $this->validatorResolver->_call('unifyDataType', 'double')); - $this->assertEquals('Boolean', $this->validatorResolver->_call('unifyDataType', 'boolean')); - $this->assertEquals('Boolean', $this->validatorResolver->_call('unifyDataType', 'bool')); - $this->assertEquals('Boolean', $this->validatorResolver->_call('unifyDataType', 'bool')); - $this->assertEquals('Number', $this->validatorResolver->_call('unifyDataType', 'number')); - $this->assertEquals('Number', $this->validatorResolver->_call('unifyDataType', 'numeric')); + public function getValidatorTypeCorrectlyRenamesPhpDataTypes() { + $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'integer')); + $this->assertEquals('Integer', $this->validatorResolver->_call('getValidatorType', 'int')); + $this->assertEquals('String', $this->validatorResolver->_call('getValidatorType', 'string')); + $this->assertEquals('Array', $this->validatorResolver->_call('getValidatorType', 'array')); + $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'float')); + $this->assertEquals('Float', $this->validatorResolver->_call('getValidatorType', 'double')); + $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'boolean')); + $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool')); + $this->assertEquals('Boolean', $this->validatorResolver->_call('getValidatorType', 'bool')); + $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'number')); + $this->assertEquals('Number', $this->validatorResolver->_call('getValidatorType', 'numeric')); } /** * @test * @author Bastian Waidelich <bastian@typo3.org> */ - public function unifyDataTypeRenamesMixedToRaw() { - $this->assertEquals('Raw', $this->validatorResolver->_call('unifyDataType', 'mixed')); + public function getValidatorTypeRenamesMixedToRaw() { + $this->assertEquals('Raw', $this->validatorResolver->_call('getValidatorType', 'mixed')); } /**