1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of byrokrat\giroapp. |
4
|
|
|
* |
5
|
|
|
* byrokrat\giroapp is free software: you can redistribute it and/or |
6
|
|
|
* modify it under the terms of the GNU General Public License as published |
7
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* byrokrat\giroapp is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU General Public License |
16
|
|
|
* along with byrokrat\giroapp. If not, see <http://www.gnu.org/licenses/>. |
17
|
|
|
* |
18
|
|
|
* Copyright 2016-18 Hannes Forsgård |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
declare(strict_types = 1); |
22
|
|
|
|
23
|
|
|
namespace byrokrat\giroapp\Plugin; |
24
|
|
|
|
25
|
|
|
use byrokrat\giroapp\Console\CommandInterface; |
26
|
|
|
use byrokrat\giroapp\Filter\FilterInterface; |
27
|
|
|
use byrokrat\giroapp\Formatter\FormatterInterface; |
28
|
|
|
use byrokrat\giroapp\Xml\XmlFormInterface; |
29
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
30
|
|
|
|
31
|
|
|
final class Plugin implements PluginInterface |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var object[] |
35
|
|
|
*/ |
36
|
|
|
private $objects; |
37
|
|
|
|
38
|
|
|
public function __construct(...$objects) |
39
|
|
|
{ |
40
|
|
|
$this->objects = $objects; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function loadPlugin(EnvironmentInterface $environment): void |
44
|
|
|
{ |
45
|
|
|
foreach ($this->objects as $item) { |
46
|
|
|
if ($item instanceof CommandInterface) { |
47
|
|
|
$environment->registerCommand($item); |
48
|
|
|
} |
49
|
|
|
if ($item instanceof EventSubscriberInterface) { |
50
|
|
|
$environment->registerSubscriber($item); |
51
|
|
|
} |
52
|
|
|
if ($item instanceof FilterInterface) { |
53
|
|
|
$environment->registerDonorFilter($item); |
54
|
|
|
} |
55
|
|
|
if ($item instanceof FormatterInterface) { |
56
|
|
|
$environment->registerDonorFormatter($item); |
57
|
|
|
} |
58
|
|
|
if ($item instanceof XmlFormInterface) { |
59
|
|
|
$environment->registerXmlForm($item); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|