[TASK][WIP] Move non class code back to source files
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Validation / PropertyError.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * This object holds validation errors for one property.
29 *
30 * @package Extbase
31 * @subpackage Validation
32 * @version $Id$
33 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
34 * @scope prototype
35 * @deprecated since Extbase 1.4.0, will be removed in Extbase 6.0
36 */
37 class Tx_Extbase_Validation_PropertyError extends Tx_Extbase_Validation_Error {
38
39 /**
40 * @var string The default (english) error message.
41 */
42 protected $message = 'Validation errors for property "%s"';
43
44 /**
45 * @var string The error code
46 */
47 protected $code = 1242859509;
48
49 /**
50 * @var string The property name
51 */
52 protected $propertyName;
53
54 /**
55 * @var array An array of Tx_Extbase_Validation_Error for the property
56 */
57 protected $errors = array();
58
59 /**
60 * Create a new property error with the given property name
61 *
62 * @param string $propertyName The property name
63 */
64 public function __construct($propertyName) {
65 $this->propertyName = $propertyName;
66 $this->message = sprintf($this->message, $propertyName);
67 }
68
69 /**
70 * Add errors
71 *
72 * @param array $errors Array of Tx_Extbase_Validation_Error for the property
73 * @return void
74 */
75 public function addErrors($errors) {
76 $this->errors = array_merge($this->errors, $errors);
77 }
78
79 /**
80 * Get all errors for the property
81 *
82 * @return array An array of Tx_Extbase_Validation_Error objects or an empty array if no errors occured for the property
83 */
84 public function getErrors() {
85 return $this->errors;
86 }
87
88 /**
89 * Get the property name
90 *
91 * @return string The property name for this error
92 */
93 public function getPropertyName() {
94 return $this->propertyName;
95 }
96
97 }
98
99 ?>