|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de> 00006 * All rights reserved 00007 * 00008 * This class is a backport of the corresponding class of FLOW3. 00009 * All credits go to the v5 team. 00010 * 00011 * This script is part of the TYPO3 project. The TYPO3 project is 00012 * free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * The GNU General Public License can be found at 00018 * http://www.gnu.org/copyleft/gpl.html. 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * An abstract composite validator with consisting of other validators 00030 * 00031 * @package Extbase 00032 * @subpackage Validation\Validator 00033 * @version $Id: AbstractCompositeValidator.php 1729 2009-11-25 21:37:20Z stucki $ 00034 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00035 * @scope prototype 00036 */ 00037 abstract class Tx_Extbase_Validation_Validator_AbstractCompositeValidator implements Tx_Extbase_Validation_Validator_ValidatorInterface, Countable { 00038 00039 /** 00040 * @var array 00041 */ 00042 protected $options = array(); 00043 00044 /** 00045 * @var Tx_Extbase_Persistence_ObjectStorage 00046 */ 00047 protected $validators; 00048 00049 /** 00050 * @var array 00051 */ 00052 protected $errors = array(); 00053 00054 /** 00055 * Constructs the validator conjunction 00056 * 00057 */ 00058 public function __construct() { 00059 $this->validators = new Tx_Extbase_Persistence_ObjectStorage(); 00060 } 00061 00062 /** 00063 * Does nothing. 00064 * 00065 * @param array $options Not used 00066 * @return void 00067 */ 00068 public function setOptions(array $options) { 00069 } 00070 00071 /** 00072 * Returns an array of errors which occurred during the last isValid() call. 00073 * 00074 * @return array An array of Tx_Extbase_Validation_Error objects or an empty array if no errors occurred. 00075 */ 00076 public function getErrors() { 00077 return $this->errors; 00078 } 00079 00080 /** 00081 * Adds a new validator to the conjunction. 00082 * 00083 * @param Tx_Extbase_Validation_Validator_ValidatorInterface $validator The validator that should be added 00084 * @return void 00085 */ 00086 public function addValidator(Tx_Extbase_Validation_Validator_ValidatorInterface $validator) { 00087 $this->validators->attach($validator); 00088 } 00089 00090 /** 00091 * Removes the specified validator. 00092 * 00093 * @param Tx_Extbase_Validation_ValidatorInterface $validator The validator to remove 00094 */ 00095 public function removeValidator(Tx_Extbase_Validation_Validator_ValidatorInterface $validator) { 00096 if (!$this->validators->contains($validator)) throw new Tx_Extbase_Validation_Exception_NoSuchValidator('Cannot remove validator because its not in the conjunction.', 1207020177); 00097 $this->validators->detach($validator); 00098 } 00099 00100 /** 00101 * Returns the number of validators contained in this conjunction. 00102 * 00103 * @return integer The number of validators 00104 */ 00105 public function count() { 00106 return count($this->validators); 00107 } 00108 } 00109 00110 ?>
1.8.0