Skip to content

Commit 736e356

Browse files
committed
TASK: Introduce ErrorHandlingService
1 parent 220afcc commit 736e356

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service;
3+
4+
/* *
5+
* This script belongs to the TYPO3 Flow package "Flowpack.ElasticSearch.ContentRepositoryAdaptor". *
6+
* *
7+
* It is free software; you can redistribute it and/or modify it under *
8+
* the terms of the GNU Lesser General Public License, either version 3 *
9+
* of the License, or (at your option) any later version. *
10+
* *
11+
* The TYPO3 project - inspiring people to share! *
12+
* */
13+
14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Indexer\Error\ErrorInterface;
15+
use TYPO3\Flow\Annotations as Flow;
16+
17+
/**
18+
* Error Handling Service
19+
*
20+
* @Flow\Scope("singleton")
21+
*/
22+
class ErrorHandlingService implements \IteratorAggregate
23+
{
24+
protected $errors = [];
25+
26+
/**
27+
* @param ErrorInterface $error
28+
*/
29+
public function log(ErrorInterface $error)
30+
{
31+
$this->errors[] = $error;
32+
$error->log();
33+
}
34+
35+
/**
36+
* @return bool
37+
*/
38+
public function hasError()
39+
{
40+
return count($this->errors) > 0;
41+
}
42+
43+
/**
44+
* @return \ArrayIterator
45+
*/
46+
public function getIterator()
47+
{
48+
return new \ArrayIterator($this->errors);
49+
}
50+
}

0 commit comments

Comments
 (0)