1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2016-2016} Andreas Heigl<[email protected]> |
4
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
5
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
6
|
|
|
* in the Software without restriction, including without limitation the rights |
7
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
8
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
9
|
|
|
* furnished to do so, subject to the following conditions: |
10
|
|
|
* The above copyright notice and this permission notice shall be included in |
11
|
|
|
* all copies or substantial portions of the Software. |
12
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
13
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
14
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
15
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
16
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
17
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
18
|
|
|
* THE SOFTWARE. |
19
|
|
|
* |
20
|
|
|
* @author Andreas Heigl<[email protected]> |
21
|
|
|
* @copyright 2016-2016 Andreas Heigl |
22
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT-License |
23
|
|
|
* @version 0.0 |
24
|
|
|
* @since 27.03.2016 |
25
|
|
|
* @link http://github.com/heiglandreas/callingallpapers |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
namespace Callingallpapers\Writer; |
29
|
|
|
|
30
|
|
|
use Callingallpapers\Entity\Cfp; |
31
|
|
|
use Org_Heigl\IteratorTrait\IteratorTrait; |
32
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
33
|
|
|
|
34
|
|
|
class WriterList implements WriterInterface, \Iterator |
35
|
|
|
{ |
36
|
|
|
use IteratorTrait; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var WriterInterface[] |
40
|
|
|
*/ |
41
|
|
|
protected $writer = []; |
42
|
|
|
|
43
|
|
|
protected $output; |
44
|
|
|
|
45
|
|
|
public function __construct() |
46
|
|
|
{ |
47
|
|
|
$this->output = new NullOutput(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get the array the iterator shall iterate over. |
52
|
|
|
* |
53
|
|
|
* @return array |
54
|
|
|
*/ |
55
|
|
|
protected function & getIterableElement() |
56
|
|
|
{ |
57
|
|
|
return $this->writer; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param Cfp $cfp |
62
|
|
|
* |
63
|
|
|
* @return String |
64
|
|
|
*/ |
65
|
|
|
public function write(Cfp $cfp) |
66
|
|
|
{ |
67
|
|
|
foreach ($this->writer as $writer) { |
68
|
|
|
$writer->setOutput($this->output); |
69
|
|
|
$writer->write($cfp); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Add a writer |
75
|
|
|
* |
76
|
|
|
* @param WriterInterface $writer |
77
|
|
|
* |
78
|
|
|
* @return void |
79
|
|
|
*/ |
80
|
|
|
public function addWriter(Writer $writer) |
81
|
|
|
{ |
82
|
|
|
$this->writer[] = $writer; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function setOutput(OutputInterface $output) |
86
|
|
|
{ |
87
|
|
|
$this->output = $output; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|