@@ -14,20 +14,20 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class KKLabsChuckConsoleExtension extends Extension |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * {@inheritdoc} |
|
| 19 | - */ |
|
| 20 | - public function load(array $configs, ContainerBuilder $container) |
|
| 21 | - { |
|
| 22 | - $configuration = new Configuration(); |
|
| 23 | - $config = $this->processConfiguration($configuration, $configs); |
|
| 17 | + /** |
|
| 18 | + * {@inheritdoc} |
|
| 19 | + */ |
|
| 20 | + public function load(array $configs, ContainerBuilder $container) |
|
| 21 | + { |
|
| 22 | + $configuration = new Configuration(); |
|
| 23 | + $config = $this->processConfiguration($configuration, $configs); |
|
| 24 | 24 | |
| 25 | - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 26 | - $loader->load('services.xml'); |
|
| 25 | + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 26 | + $loader->load('services.xml'); |
|
| 27 | 27 | |
| 28 | - $container->setParameter('chuck.who.first_name', $config['who']['first_name']); |
|
| 29 | - $container->setParameter('chuck.who.last_name', $config['who']['last_name']); |
|
| 30 | - $container->setParameter('chuck.timeout', $config['timeout']); |
|
| 31 | - $container->setParameter('chuck.enabled_environments', $config['environments']); |
|
| 32 | - } |
|
| 28 | + $container->setParameter('chuck.who.first_name', $config['who']['first_name']); |
|
| 29 | + $container->setParameter('chuck.who.last_name', $config['who']['last_name']); |
|
| 30 | + $container->setParameter('chuck.timeout', $config['timeout']); |
|
| 31 | + $container->setParameter('chuck.enabled_environments', $config['environments']); |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -12,31 +12,31 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Configuration implements ConfigurationInterface |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * {@inheritdoc} |
|
| 17 | - */ |
|
| 18 | - public function getConfigTreeBuilder() |
|
| 19 | - { |
|
| 20 | - $treeBuilder = new TreeBuilder(); |
|
| 21 | - $rootNode = $treeBuilder->root('kk_labs_chuck_console'); |
|
| 15 | + /** |
|
| 16 | + * {@inheritdoc} |
|
| 17 | + */ |
|
| 18 | + public function getConfigTreeBuilder() |
|
| 19 | + { |
|
| 20 | + $treeBuilder = new TreeBuilder(); |
|
| 21 | + $rootNode = $treeBuilder->root('kk_labs_chuck_console'); |
|
| 22 | 22 | |
| 23 | - $rootNode |
|
| 24 | - ->children() |
|
| 25 | - ->arrayNode('who') |
|
| 26 | - ->addDefaultsIfNotSet() |
|
| 27 | - ->children() |
|
| 28 | - ->scalarNode('first_name')->defaultValue('Chuck')->end() |
|
| 29 | - ->scalarNode('last_name')->defaultValue('Norris')->end() |
|
| 30 | - ->end() |
|
| 31 | - ->end()//who |
|
| 32 | - ->scalarNode('timeout') |
|
| 33 | - ->defaultValue(10) |
|
| 34 | - ->end() |
|
| 35 | - ->arrayNode('environments') |
|
| 36 | - ->prototype('scalar')->end() |
|
| 37 | - ->defaultValue(['dev']) |
|
| 38 | - ->end(); |
|
| 23 | + $rootNode |
|
| 24 | + ->children() |
|
| 25 | + ->arrayNode('who') |
|
| 26 | + ->addDefaultsIfNotSet() |
|
| 27 | + ->children() |
|
| 28 | + ->scalarNode('first_name')->defaultValue('Chuck')->end() |
|
| 29 | + ->scalarNode('last_name')->defaultValue('Norris')->end() |
|
| 30 | + ->end() |
|
| 31 | + ->end()//who |
|
| 32 | + ->scalarNode('timeout') |
|
| 33 | + ->defaultValue(10) |
|
| 34 | + ->end() |
|
| 35 | + ->arrayNode('environments') |
|
| 36 | + ->prototype('scalar')->end() |
|
| 37 | + ->defaultValue(['dev']) |
|
| 38 | + ->end(); |
|
| 39 | 39 | |
| 40 | - return $treeBuilder; |
|
| 41 | - } |
|
| 40 | + return $treeBuilder; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -13,44 +13,44 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class ConsoleTerminateListener |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @var ChuckAPIService |
|
| 18 | - */ |
|
| 19 | - private $chuckApiService; |
|
| 16 | + /** |
|
| 17 | + * @var ChuckAPIService |
|
| 18 | + */ |
|
| 19 | + private $chuckApiService; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - private $enabledEnvironments; |
|
| 21 | + /** |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + private $enabledEnvironments; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 29 | - private $env; |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | + private $env; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * ConsoleTerminateListener constructor. |
|
| 33 | - * @param ChuckAPIService $chuckAPIService |
|
| 34 | - */ |
|
| 35 | - public function __construct(ChuckAPIService $chuckAPIService, $environments = [], $env) |
|
| 36 | - { |
|
| 37 | - $this->chuckApiService = $chuckAPIService; |
|
| 38 | - $this->enabledEnvironments = $environments; |
|
| 39 | - $this->env = $env; |
|
| 40 | - } |
|
| 31 | + /** |
|
| 32 | + * ConsoleTerminateListener constructor. |
|
| 33 | + * @param ChuckAPIService $chuckAPIService |
|
| 34 | + */ |
|
| 35 | + public function __construct(ChuckAPIService $chuckAPIService, $environments = [], $env) |
|
| 36 | + { |
|
| 37 | + $this->chuckApiService = $chuckAPIService; |
|
| 38 | + $this->enabledEnvironments = $environments; |
|
| 39 | + $this->env = $env; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param ConsoleTerminateEvent $event |
|
| 44 | - */ |
|
| 45 | - public function onConsoleTerminate(ConsoleTerminateEvent $event) |
|
| 46 | - { |
|
| 47 | - if (!$event->getCommand() instanceof ChuckCommand && in_array($this->env, $this->enabledEnvironments)) { |
|
| 48 | - try { |
|
| 49 | - $fact = $this->chuckApiService->getFact(); |
|
| 50 | - $event->getOutput()->writeln($fact); |
|
| 51 | - } catch (ConnectException $e) { |
|
| 52 | - //do nothing; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - } |
|
| 42 | + /** |
|
| 43 | + * @param ConsoleTerminateEvent $event |
|
| 44 | + */ |
|
| 45 | + public function onConsoleTerminate(ConsoleTerminateEvent $event) |
|
| 46 | + { |
|
| 47 | + if (!$event->getCommand() instanceof ChuckCommand && in_array($this->env, $this->enabledEnvironments)) { |
|
| 48 | + try { |
|
| 49 | + $fact = $this->chuckApiService->getFact(); |
|
| 50 | + $event->getOutput()->writeln($fact); |
|
| 51 | + } catch (ConnectException $e) { |
|
| 52 | + //do nothing; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | } |