Extbase:
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Property / MappingResults.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * The Mapping Results
27 *
28 * @package TYPO3
29 * @subpackage extbase
30 * @version $Id: $
31 * @scope prototype
32 */
33 class Tx_Extbase_Property_MappingResults {
34
35 /**
36 * @var array An array of the occured errors
37 */
38 protected $errors = array();
39
40 /**
41 * @var array An array of the occured warnings
42 */
43 protected $warnings = array();
44
45 /**
46 * Adds an error to the mapping results. This might be for example a
47 * validation or mapping error
48 *
49 * @param string $error The occured error
50 * @param string $propertyName The name of the property which caused the error
51 */
52 public function addError($error, $propertyName) {
53 $this->errors[$propertyName] = $error;
54 }
55
56 /**
57 * Returns all errors that occured so far
58 *
59 * @return array Array of error messages
60 */
61 public function getErrors() {
62 return $this->errors;
63 }
64
65 /**
66 * Returns true if any error was recognized
67 *
68 * @return boolean True if an error occured
69 */
70 public function hasErrors() {
71 return (count($this->errors) > 0);
72 }
73
74 /**
75 * Adds a warning to the mapping results. This might be for example a
76 * property that could not be mapped but wasn't marked as required.
77 *
78 * @param string $warning The occured warning
79 * @param string $propertyName The name of the property which caused the error
80 */
81 public function addWarning($warning, $propertyName) {
82 $this->warnings[$propertyName] = $warning;
83 }
84
85 /**
86 * Returns all warnings that occured so far
87 *
88 * @return array Array of warnings
89 */
90 public function getWarnings() {
91 return $this->warnings;
92 }
93
94 /**
95 * Returns TRUE if any warning was recognized
96 *
97 * @return boolean TRUE if a warning occured
98 */
99 public function hasWarnings() {
100 return (count($this->warnings) > 0);
101 }
102 }
103
104 ?>