-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd
executable file
·34 lines (28 loc) · 1.18 KB
/
cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
$container = new ContainerBuilder();
// Config
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('config.yml');
// Param
$dispatcherId = $container->getParameter('dispatcher_id');
// CompilerPass
$container->addCompilerPass(new RegisterListenersPass($dispatcherId));
$container->setDefinition($dispatcherId, new Definition(
'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher',
[new Reference('service_container')]
));
$container->compile();
$dispatcher = $container->get($dispatcherId);
$output = $container->get('symfony.console.output');
/** @var Symfony\Component\Console\Application $application */
$application = $container->get('cmd');
$application->setDispatcher($dispatcher);
$application->run(null, $output);