These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace DoctrineModule\Service; |
||
6 | |||
7 | use Interop\Container\ContainerInterface; |
||
8 | use Laminas\EventManager\EventManagerInterface; |
||
9 | use Laminas\ServiceManager\FactoryInterface; |
||
10 | use Laminas\ServiceManager\ServiceLocatorInterface; |
||
11 | use Symfony\Component\Console\Application; |
||
12 | use Symfony\Component\Console\Helper\HelperSet; |
||
13 | |||
14 | /** |
||
15 | * CLI Application ServiceManager factory responsible for instantiating a Symfony CLI application |
||
16 | * |
||
17 | * @link http://www.doctrine-project.org/ |
||
18 | */ |
||
19 | class CliFactory implements FactoryInterface |
||
0 ignored issues
–
show
|
|||
20 | { |
||
21 | /** @var EventManagerInterface */ |
||
22 | protected $events; |
||
23 | |||
24 | /** @var HelperSet */ |
||
25 | protected $helperSet; |
||
26 | |||
27 | /** @var mixed[] */ |
||
28 | protected $commands = []; |
||
29 | |||
30 | public function getEventManager(ContainerInterface $container) : EventManagerInterface |
||
31 | { |
||
32 | if ($this->events === null) { |
||
33 | $events = $container->get('EventManager'); |
||
34 | |||
35 | $events->addIdentifiers([self::class, 'doctrine']); |
||
36 | |||
37 | $this->events = $events; |
||
38 | } |
||
39 | |||
40 | return $this->events; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritDoc} |
||
45 | * |
||
46 | * @return Application |
||
47 | */ |
||
48 | public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) |
||
49 | { |
||
50 | $cli = new Application(); |
||
51 | $cli->setName('DoctrineModule Command Line Interface'); |
||
52 | $cli->setHelperSet(new HelperSet()); |
||
53 | $cli->setCatchExceptions(true); |
||
54 | $cli->setAutoExit(false); |
||
55 | |||
56 | // Load commands using event |
||
57 | $this->getEventManager($container)->trigger('loadCli.post', $cli, ['ServiceManager' => $container]); |
||
58 | |||
59 | return $cli; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritDoc} |
||
64 | * |
||
65 | * @return Application |
||
66 | */ |
||
67 | public function createService(ServiceLocatorInterface $container) |
||
68 | { |
||
69 | return $this($container, Application::class); |
||
70 | } |
||
71 | } |
||
72 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.