* moved all validation code to the Argument
authorJochen Rau <j.rau@web.de>
Fri, 27 Feb 2009 23:17:11 +0000 (23:17 +0000)
committerJochen Rau <j.rau@web.de>
Fri, 27 Feb 2009 23:17:11 +0000 (23:17 +0000)
* now setValue() validates the value before it is set in the Argument
* deleted some unnecessary files (we don't support validation chaining by now)

17 files changed:
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_AbstractController.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_Argument.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_ArgumentsValidator.php [deleted file]
typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Validation_Exception_InvalidChainIndex.php [deleted file]
typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Error.php [deleted file]
typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorResolver.php [deleted file]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_Alphanumeric.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_Float.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_Integer.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_NotEmpty.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_Number.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_NumberRange.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_RegularExpression.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_Text.php
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Validation_Validator_UUID.php
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_TemplateView.php
typo3/sysext/extbase/class.tx_extmvc_dispatcher.php

index 40417f7..a3faa68 100755 (executable)
@@ -24,7 +24,6 @@ declare(ENCODING = 'utf-8');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_ControllerInterface.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_Arguments.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Exception/TX_EXTMVC_Exception_StopAction.php');
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Validation/TX_EXTMVC_Validation_ValidatorResolver.php');
 
 /**
  * An abstract base class for Controllers
@@ -61,31 +60,6 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         */
        protected $arguments;
        
-       /**
-        * @var TX_EXTMVC_Controller_Arguments Arguments passed to the controller
-        */
-       protected $validator;
-       
-       /**
-        * @var array Validation errors
-        */
-       protected $errors = array();
-       
-       /**
-        * @var array Validation warnings
-        */
-       protected $warnings = array();
-       
-       /**
-        * @var array An array of allowed arguemnt names (or regular expressions matching those)
-        */
-       protected $allowedArguments = array('.*');
-
-       /**
-        * @var array An array of names of the required arguments (or regular expressions matching those)
-        */
-       protected $requiredArguments = array();
-
        /**
         * Constructs the controller.
         *
@@ -95,9 +69,6 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         */
        public function __construct() {
                $this->arguments = t3lib_div::makeInstance('TX_EXTMVC_Controller_Arguments');
-               list(, $this->extensionKey) = explode('_', strtolower(get_class($this)));
-               // debug($this->extensionKey));
-               // $this->extension = $packageManager->getPackage($this->extensionKey);
        }
 
        /**
@@ -207,127 +178,18 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         * @author Robert Lemke <robert@typo3.org>
         */
        protected function mapRequestArgumentsToLocalArguments() {
-               $this->setAllowedArguments(array_merge($this->arguments->getArgumentNames(), $this->arguments->getArgumentShortNames()));
-               $this->validator = new TX_EXTMVC_Controller_ArgumentsValidator($this->arguments);
-               foreach ($this->request->getArguments() as $requestArgument) {
-                       if ($this->isAllowedArgument($requestArgument)) {
-                               $argumentName = $requestArgument->getName();
-                               $argumentValue = $requestArgument->getValue();
-                               if (!$this->setArgumentValue($argumentName, $argumentValue)) {                                  
-                                       if ($this->isRequiredArgument($requestArgument)) {
-                                               $this->errors[] = 'The argument "' . $argumentName . '" could not be set, but was marked as required.';
-                                       } else {
-                                               $this->warnings[] = 'The argument "' . $argumentName . '" could not be set.';
-                                       }
-                               }
-                       } else {
-                               $this->warnings[] = 'The argument "' . $requestArgument->getName() . '" was not allowed not be set.';
+               $requestArguments = $this->request->getArguments();
+               foreach ($this->arguments as $argument) {
+                       $argumentName = $argument->getName();
+                       $argumentShortName = $argument->getShortName();
+                       if (array_key_exists($argumentName, $requestArguments)) {
+                               $argument->setValue($requestArguments[$argumentName]->getValue());
+                       } elseif ($argumentShortName !== NULL && array_key_exists($argumentShortName, $requestArguments)) {
+                               $argument->setValue($requestArguments[$argumentShortName]->getValue());
                        }
                }
-               
-               if(!$isValid) {
-                       // TODO Do something with the warnings and error messages
-                       // debug($this->errors);
-                       // debug($this->warnings);
-               }
-       }
-       
-       /**
-        * Defines the property names which are allowed for mapping.
-        *
-        * @param  array $allowedArguments: An array of allowed argument names.
-        * @return void
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       protected function setAllowedArguments(array $allowedArguments) {
-               $this->allowedArguments = $allowedArguments;
        }
-
-       /**
-        * Returns an array of strings defining the allowed properties for mapping.
-        *
-        * @return array The allowed properties
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       protected function getAllowedArguments() {
-               return $this->allowedArguments;
-       }
-       
-       /**
-        * Checks if the give argument is among the allowed arguments. Each entry in this array may be a regular expression.
-        *
-        * @param TX_EXTMVC_Controller_Argument $argument The Argument to check for
-        * @return boolean TRUE if the argument is allowed, else FALSE
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        * @see map()
-        */
-       protected function isAllowedArgument(TX_EXTMVC_Controller_Argument $argument) {
-               if (current($this->allowedArguments) === '.*') return TRUE;
-
-               $isAllowed = FALSE;
-               foreach ($this->allowedArguments as $allowedArgumentName) {
-                       if (preg_match('/^' . $allowedArgumentName . '$/', $argument->getName()) === 1) {
-                               $isAllowed = TRUE;
-                               break;
-                       }
-               }
-               return $isAllowed;
-       }
-
-       /**
-        * Checks if the given argument is required
-        *
-        * @param TX_EXTMVC_Controller_Argument $argument The argument to check for
-        * @return boolean TRUE if the property is required, else FALSE
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       protected function isRequiredArgument($argument) {
-               if ($this->arguments[$argument->getName()] instanceof TX_EXTMVC_Controller_Argument) {
-                       return (boolean)$this->arguments[$argument->getName()]->isRequired();
-               } else {
-                       return FALSE;
-               }
-       }
-
-       
-       /**
-        * Sets the given value of the specified property at the target object.
-        *
-        * @param string $propertyName Name of the property to set
-        * @param string $propertyValue Value of the property
-        * @return boolean Returns TRUE, if the setting was successfull
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @see map()
-        */
-       protected function setArgumentValue($argumentName, $argumentValue) {
-               if ($this->validator !== NULL) {
-                       $validatorErrors = $this->createNewValidationErrorsObject();                    
-                       if (!$this->validator->isValidArgument($argumentName, $argumentValue, $validatorErrors)) {
-                               foreach ($validatorErrors as $error) {
-                                       $this->errors[] = $error;
-                               }
-                               return FALSE;
-                       }
-               }
-               $argument = $this->arguments[$argumentName];
-               $argument->setValue($argumentValue);
-               return TRUE;
-       }
-       
-       /**
-        * This is a factory method to get a clean validation errors object
-        *
-        * @return TX_EXTMVC_Validation_Errors An empty errors object
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       protected function createNewValidationErrorsObject() {
-               return t3lib_div::makeInstance('TX_EXTMVC_Validation_Errors');
-       }
-
-
-               
+                       
 }
 
 ?>
\ No newline at end of file
index f2c35da..96c2afb 100644 (file)
@@ -64,7 +64,7 @@ class TX_EXTMVC_Controller_Argument {
         * The argument is valid
         * @var boolean
         */
-       protected $isValid = TRUE;
+       protected $isValid = NULL;
 
        /**
         * Any error (TX_EXTMVC_Error_Error) that occured while initializing this argument (e.g. a mapping error)
@@ -72,12 +72,6 @@ class TX_EXTMVC_Controller_Argument {
         */
        protected $errors = array();
 
-       /**
-        * Any warning (TX_EXTMVC_Error_Warning) that occured while initializing this argument (e.g. a mapping warning)
-        * @var array
-        */
-       protected $warnings = array();
-
        /**
         * The property validator for this argument
         * @var TX_EXTMVC_Validation_ValidatorInterface
@@ -153,14 +147,11 @@ class TX_EXTMVC_Controller_Argument {
         */
        public function setDataType($dataType) {
                $this->dataType = ($dataType != '' ? $dataType : 'Text');
-
                $dataTypeValidatorClassName = 'TX_EXTMVC_Validation_Validator_' . $this->dataType;
                $classFilePathAndName = t3lib_extMgm::extPath('extmvc') . 'Classes/Validation/Validator/' . $dataTypeValidatorClassName . '.php';
                if (isset($classFilePathAndName) && file_exists($classFilePathAndName)) {                       
                        require_once($classFilePathAndName);
                        $this->datatypeValidator = t3lib_div::makeInstance($dataTypeValidatorClassName);
-               } else {
-                       // TODO Should we throw an exception at this point?
                }
                return $this;
        }
@@ -206,7 +197,9 @@ class TX_EXTMVC_Controller_Argument {
         * @author Robert Lemke <robert@typo3.org>
         */
        public function setValue($value) {
-               $this->value = $value;
+               if ($this->isValidValueForThisArgument($value)) {
+                       $this->value = $value;
+               }
                return $this;
        }
 
@@ -231,14 +224,29 @@ class TX_EXTMVC_Controller_Argument {
        }
 
        /**
-        * Set the validity status of the argument
+        * undocumented function
         *
-        * @param boolean TRUE if the argument is valid, FALSE otherwise
-        * @return void
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function setValidity($isValid) {
+        * @param string $value 
+        * @return boolean TRUE if the value is valid for this argument, otherwise FALSE
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       protected function isValidValueForThisArgument($value) {
+               $isValid = TRUE;
+               $validatorErrors = t3lib_div::makeInstance('TX_EXTMVC_Validation_Errors');
+               if ($this->getValidator() != NULL) {
+                       $isValid &= $this->getValidator()->isValidProperty($value, $validatorErrors);
+               } elseif ($this->getDatatypeValidator() != NULL) {
+                       $isValid = $this->getDatatypeValidator()->isValidProperty($value, $validatorErrors);                    
+               } else {
+                       throw new TX_EXTMVC_Validation_NoValidatorFound('No appropriate validator for the argument "' . $this->getName() . '" was found.', 1235748909);
+               }
+               if (!$isValid) {
+                       foreach ($validatorErrors as $error) {
+                               $this->addError($error);
+                       }
+               }
                $this->isValid = $isValid;
+               return (boolean)$isValid;
        }
 
        /**
@@ -254,11 +262,11 @@ class TX_EXTMVC_Controller_Argument {
        /**
         * Add an initialization error (e.g. a mapping error)
         *
-        * @param TX_EXTMVC_Error_Error An error object
+        * @param string An error text
         * @return void
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
         */
-       public function addError(TX_EXTMVC_Error_Error $error) {
+       public function addError($error) {
                $this->errors[] = $error;
        }
 
@@ -273,28 +281,6 @@ class TX_EXTMVC_Controller_Argument {
                return $this->errors;
        }
 
-       /**
-        * Add an initialization warning (e.g. a mapping warning)
-        *
-        * @param TX_EXTMVC_Error_Warning A warning object
-        * @return void
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function addWarning(TX_EXTMVC_Error_Warning $warning) {
-               $this->warnings[] = $warning;
-       }
-
-       /**
-        * Get all initialization warnings
-        *
-        * @return array An array containing TX_EXTMVC_Error_Warning objects
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        * @see addWarning(TX_EXTMVC_Error_Warning $warning)
-        */
-       public function getWarnings() {
-               return $this->warnings;
-       }
-
        /**
         * Set an additional validator
         *
diff --git a/typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_ArgumentsValidator.php b/typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_ArgumentsValidator.php
deleted file mode 100644 (file)
index c3738aa..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Validation/TX_EXTMVC_Validation_Errors.php');
-
-/**
- * Validator for the controller arguments object
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- * @scope prototype
- */
-class TX_EXTMVC_controller_ArgumentsValidator {
-
-       /**
-        * @var TX_EXTMVC_Controller_Arguments The registered arguments with the specified property validators
-        */
-       protected $registeredArguments;
-
-       /**
-        * Constructor
-        *
-        * @param TX_EXTMVC_Controller_Arguments The registered arguments with the specified property editors
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function __construct(TX_EXTMVC_Controller_Arguments $registeredArguments) {
-               $this->registeredArguments = $registeredArguments;
-       }
-
-       /**
-        * Returns TRUE, if the given argument ($argumentValue) is a valid value for the property ($argumentName) of the class ($className).
-        * Any errors will be stored in the given errors object. If at least one error occurred, the result is FALSE.
-        *
-        * @param string $argumentName: The name of the argument for wich the value should be validated
-        * @param object $argumentValue: The value that should be validated
-        * @return boolean TRUE if the value could be validated for the given property, FALSE if an error occured
-        */
-       public function isValidArgument($argumentName, $argumentValue, TX_EXTMVC_Validation_Errors &$errors) {
-               $isValid = TRUE;
-               if ($this->registeredArguments[$argumentName]->getValidator() != NULL) {
-                       $isValid &= $this->registeredArguments[$argumentName]->getValidator()->isValidProperty($argumentValue, $errors);
-               } elseif ($this->registeredArguments[$argumentName]->getDatatypeValidator() != NULL) {
-                       $isValid = $this->registeredArguments[$argumentName]->getDatatypeValidator()->isValidProperty($argumentValue, $errors);                 
-               } else {
-                       throw new TX_EXTMVC_Validation_NoValidatorFound('No appropriate validator for the argument "' . $argumentName . '" was found.', 1235748909);
-               }
-
-               return (boolean)$isValid;
-       }
-       
-       /**
-        * This is a factory method to get a clean validation errors object
-        *
-        * @return TX_EXTMVC_Validation_Errors An empty errors object
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       protected function createNewValidationErrorsObject() {
-               return t3lib_div::makeInstance('TX_EXTMVC_Validation_Errors');
-       }
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Validation_Exception_InvalidChainIndex.php b/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Validation_Exception_InvalidChainIndex.php
deleted file mode 100644 (file)
index 8ac033d..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * @package FLOW3
- * @subpackage Validation
- * @version $ID:$
- */
-
-/**
- * An "Invalid Chain Index" Exception for a validator chain
- *
- * @package FLOW3
- * @subpackage Validation
- * @version $ID:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class TX_EXTMVC_Validation_InvalidChainIndex extends TX_EXTMVC_Validation_Exception {
-
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Error.php b/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Error.php
deleted file mode 100755 (executable)
index 5e3500d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * This object holds a validation error.
- *
- * @version $ID:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- * @scope prototype
- */
-class TX_EXTMVC_Validation_Error extends TX_EXTMVC_Error_Error {
-
-       /**
-        * @var string The default (english) error message.
-        */
-       protected $message = 'Unknown validation error';
-
-       /**
-        * @var string The error code
-        */
-       protected $code = 1201447005;
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorResolver.php b/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorResolver.php
deleted file mode 100644 (file)
index 071c66a..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * Validator resolver to automatically find a appropriate validator for a given subject
- *
- * @version $ID:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class TX_EXTMVC_Validation_ValidatorResolver {
-
-       /**
-        * Returns an object of an appropriate validator for the given class. If no validator is available
-        * a TX_EXTMVC_Validation_Exception_NoValidatorFound exception is thrown.
-        * @param string The classname for which validator is needed
-        * @return object The resolved validator object
-        * @throws TX_EXTMVC_Validation_Exception_NoValidatorFound
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function resolveValidator($class) {
-               try {
-                       $validatorClassName = $class . 'Validator';
-                       $classNameParts = explode('_', $className);
-                       if ($classNameParts[0] === 'ux') {
-                               array_shift($classNameParts);
-                       }
-                       if (count($classNameParts) > 2 && $classNameParts[0] === 'TX') {
-                               $classFilePathAndName = t3lib_extMgm::extPath(strtolower($classNameParts[1])) . 'Classes/';
-                               $classFilePathAndName .= implode(array_slice($classNameParts, 2, -1), '/') . '/';
-                               $classFilePathAndName .= implode('_', $classNameParts) . '.php';
-                       }
-                       if (isset($classFilePathAndName) && file_exists($classFilePathAndName)) require_once($classFilePathAndName);            
-                       // if (!$this->objectManager->isObjectRegistered($validatorName)) throw new \F3\FLOW3\Validation\Exception\NoValidatorFound('No validator with name ' . $validatorName . ' found!', 1211036055);
-                       // $validator = $this->objectManager->getObject($validatorName);
-                       // if (!($validator instanceof \F3\FLOW3\Validation\ObjectValidatorInterface)) throw new \F3\FLOW3\Validation\Exception\NoValidatorFound('The found validator class did not implement \F3\FLOW3\Validation\ObjectValidatorInterface', 1211036068);
-                       return $validator;
-               } catch (TX_EXTMVC_Validation_Exception_NoValidatorFound $exception) {
-                       $this->validator = NULL;
-               }
-       }
-
-       /**
-        * Returns the name of an appropriate validator for the given class. If no validator is available
-        * a TX_EXTMVC_Validation_Exception_NoValidatorFound exception is thrown.
-        * @param string The classname for which validator is needed
-        * @return object The resolved validator object
-        * @throws TX_EXTMVC_Validation_Exception_NoValidatorFound
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function resolveValidatorName($class) {
-               $validatorName = $class . 'Validator';
-               if (!$this->objectManager->isObjectRegistered($validatorName)) throw new TX_EXTMVC_Validation_Exception_NoValidatorFound('No validator with name ' . $validatorName . ' found!', 1211036084);
-               $validator = $this->objectManager->getObject($validatorName);
-               if (!($validator instanceof TX_EXTMVC_Validation_ObjectValidatorInterface)) throw new TX_EXTMVC_Validation_Exception_NoValidatorFound('The found validator class did not implement TX_EXTMVC_Validation_ObjectValidatorInterface', 1211036095);
-               return $validatorName;
-       }
-}
-
-?>
\ No newline at end of file
index 23af6df..d079039 100644 (file)
@@ -42,9 +42,7 @@ class TX_EXTMVC_Validation_Validator_Alphanumeric {
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
-
                if (is_string($propertyValue) && preg_match('/^[a-z0-9]*$/i', $propertyValue)) return TRUE;
-
                $errors->append('The given subject was not a valid integer.');
                return FALSE;
        }
index 0d221ce..ebabaf2 100644 (file)
@@ -41,10 +41,8 @@ class TX_EXTMVC_Validation_Validator_Float {
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
-
                if (is_float($propertyValue)) return TRUE;
                if (is_string($propertyValue) && strpos($propertyValue, '.') && preg_match('/^[0-9.e+-]+$/', $propertyValue)) return TRUE;
-
                $errors->append('The given subject was not a valid float.');
                return FALSE;
        }
index ee363ed..00047a5 100644 (file)
@@ -42,7 +42,6 @@ class TX_EXTMVC_Validation_Validator_Integer {
         */
        public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
                if (filter_var($propertyValue, FILTER_VALIDATE_INT) !== FALSE) return TRUE;
-
                $errors->append('The given subject was not a valid integer.');
                return FALSE;
        }
index 93b596d..8537cc2 100644 (file)
@@ -49,7 +49,6 @@ class TX_EXTMVC_Validation_Validator_NotEmpty {
                        $errors->append('The given subject was empty.');
                        return FALSE;
                }
-
                return TRUE;
        }
 }
index 955af7b..ac38821 100644 (file)
@@ -41,9 +41,7 @@ class TX_EXTMVC_Validation_Validator_Number {
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
-
                if (is_numeric($propertyValue)) return TRUE;
-
                $errors->append('The given subject was not a valid number.');
                return FALSE;
        }
index a2fe523..daec419 100644 (file)
@@ -69,10 +69,8 @@ class TX_EXTMVC_Validation_Validator_NumberRange {
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
         */
        public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
-
                if (!is_numeric($propertyValue)) $errors->append('The given subject was not a valid number.');
                if ($propertyValue < $this->startRange || $propertyValue > $this->endRange) $errors->append('The given subject was not in the valid range (' . $this->startRange . ', ' . $this->endRange . ').');
-
                if (count($errors) > 0) return FALSE;
                return TRUE;
        }
index 7ba7f04..c44919d 100644 (file)
@@ -56,12 +56,10 @@ class TX_EXTMVC_Validation_Validator_RegularExpression {
         * @author Karsten Dambekalns <karsten@typo3.org>
         */
        public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
-
                if (!is_string($propertyValue) || preg_match($this->regularExpression, $propertyValue) === 0) {
                        $errors->append('The given subject did not match the pattern.');
                        return FALSE;
                }
-
                return TRUE;
        }
 }
index c3c0b99..7dbb68f 100644 (file)
@@ -41,10 +41,9 @@ class TX_EXTMVC_Validation_Validator_Text {
         */
        public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
                if ($propertyValue !== filter_var($propertyValue, FILTER_SANITIZE_STRING)) {
-                       $errors->append('The given subject was not a valid text (contained XML tags)."');
+                       $errors->append('The given subject was not a valid text (e.g. contained XML tags)."');
                        return FALSE;
                }
-
                return TRUE;
        }
 }
index 128e8da..b213d40 100644 (file)
@@ -45,7 +45,6 @@ class TX_EXTMVC_Validation_Validator_UUID {
                        $errors->append('The given subject was not a valid UUID.');
                        return FALSE;
                }
-
                return TRUE;
        }
 }
index 7f058ed..4110798 100644 (file)
@@ -82,7 +82,7 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
         *
         * @var tslib_cObj
         **/
-       protected $cObj;
+       private $cObj;
        
        public function __construct() {
                $this->initializeView();
@@ -96,7 +96,6 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
         */
        protected function initializeView() {
                $this->cObj = t3lib_div::makeInstance('tslib_cObj');
-               // tslib_eidtools::initLanguage();
        }
 
        /**
@@ -284,6 +283,7 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
        }
                
        protected function removeUnfilledMarkers(&$content) {
+               // TODO remove also comments
                $content = preg_replace('/###.*###/msU', '', $content);
        }
 
index 94802d8..ca5e29f 100644 (file)
@@ -83,11 +83,10 @@ class TX_EXTMVC_Dispatcher {
         * @param String $content The content
         * @param array|NULL $configuration The TS configuration array
         * @return String $content The processed content
-        * @author Robert Lemke <robert@typo3.org>
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>    
         * @author Jochen Rau <jochen.rau@typoplanet.de>
         */
        public function dispatch($content, $configuration) {
+               // TODO Add an AJAX dispatcher
                // debug($configuration);
                $request = t3lib_div::makeInstance('TX_EXTMVC_Web_Request');
                $request->setControllerExtensionKey(strtolower($configuration['extension']));
@@ -97,7 +96,6 @@ class TX_EXTMVC_Dispatcher {
                foreach (t3lib_div::GParrayMerged('tx_' . strtolower($configuration['extension'])) as $key => $value) {
                        $argument = new TX_EXTMVC_Controller_Argument($key, 'Raw');
                        $argument->setValue($value);
-                       $argument->setValidity(FALSE);
                        $arguments->addArgument($argument);
                }
                $request->setArguments($arguments);
@@ -114,7 +112,8 @@ class TX_EXTMVC_Dispatcher {
                try {
                        $controller->processRequest($request, $response);                       
                } catch (TX_EXTMVC_Exception_StopAction $ignoredException) {
-               }               
+               }
+               // TODO catch $this->cObj->convertToUserIntObject();
                $session->commit();
                $session->clear();