2 namespace TYPO3\CMS\Extbase\Error;
85 if ($this->parent !== $parent) {
108 $this->errors[] = $error;
121 $this->warnings[] = $warning;
134 $this->notices[] = $notice;
179 reset($this->errors);
180 return current($this->errors);
191 reset($this->warnings);
192 return current($this->warnings);
203 reset($this->notices);
204 return current($this->notices);
219 if ($propertyPath ===
'' || $propertyPath === null) {
222 if (strpos($propertyPath,
'.') !==
false) {
225 if (!isset($this->propertyResults[$propertyPath])) {
226 $this->propertyResults[$propertyPath] =
new Result();
227 $this->propertyResults[$propertyPath]->setParent($this);
229 return $this->propertyResults[$propertyPath];
240 if (empty($pathSegments)) {
244 $propertyName = array_shift($pathSegments);
246 if (!isset($this->propertyResults[$propertyName])) {
247 $this->propertyResults[$propertyName] =
new Result();
248 $this->propertyResults[$propertyName]->setParent($this);
251 return $this->propertyResults[$propertyName]->recurseThroughResult($pathSegments);
262 $this->errorsExist =
true;
263 if ($this->parent !== null) {
264 $this->parent->setErrorsExist();
276 $this->warningsExist =
true;
277 if ($this->parent !== null) {
278 $this->parent->setWarningsExist();
290 $this->noticesExist =
true;
291 if ($this->parent !== null) {
292 $this->parent->setNoticesExist();
313 $this->errors = array();
314 $this->notices = array();
315 $this->warnings = array();
317 $this->warningsExist =
false;
318 $this->noticesExist =
false;
319 $this->errorsExist =
false;
321 $this->propertyResults = array();
333 if (!empty($this->{$propertyName})) {
336 foreach ($this->propertyResults as $subResult) {
337 if ($subResult->{$checkerMethodName}()) {
350 public function hasErrors()
352 return $this->hasProperty(
'errors',
'hasErrors');
361 public function hasWarnings()
363 return $this->hasProperty(
'warnings',
'hasWarnings');
372 public function hasNotices()
374 return $this->hasProperty(
'notices',
'hasNotices');
385 public function getFlattenedErrors()
388 $this->flattenTree(
'errors', $result, array());
400 public function getFlattenedWarnings()
403 $this->flattenTree(
'warnings', $result, array());
415 public function getFlattenedNotices()
418 $this->flattenTree(
'notices', $result, array());
432 public function flattenTree($propertyName, &$result, $level)
434 if (!empty($this->$propertyName)) {
435 $result[implode(
'.', $level)] = $this->$propertyName;
437 foreach ($this->propertyResults as $subPropertyName => $subResult) {
438 array_push($level, $subPropertyName);
439 $subResult->flattenTree($propertyName, $result, $level);
451 public function merge(
Result $otherResult)
453 if ($otherResult->errorsExist) {
454 $this->mergeProperty($otherResult,
'getErrors',
'addError');
456 if ($otherResult->warningsExist) {
457 $this->mergeProperty($otherResult,
'getWarnings',
'addWarning');
459 if ($otherResult->noticesExist) {
460 $this->mergeProperty($otherResult,
'getNotices',
'addNotice');
463 foreach ($otherResult->
getSubResults() as $subPropertyName => $subResult) {
465 if (array_key_exists($subPropertyName, $this->propertyResults) && $this->propertyResults[$subPropertyName]->hasMessages()) {
466 $this->forProperty($subPropertyName)->merge($subResult);
468 $this->propertyResults[$subPropertyName] = $subResult;
469 $subResult->setParent($this);
482 protected function mergeProperty(
Result $otherResult, $getterName, $adderName)
484 foreach ($otherResult->$getterName() as $messageInOtherResult) {
485 $this->$adderName($messageInOtherResult);
494 public function getSubResults()
496 return $this->propertyResults;