Skip to content

Commit

Permalink
#148 Update services (step 1) according to Symfony best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
njoubert-cleverage committed Oct 22, 2024
1 parent fff486e commit 719c9ee
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 32 deletions.
32 changes: 26 additions & 6 deletions config/services/command.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
services:
CleverAge\ProcessBundle\Command\:
resource: '../../../Command/*'
autowire: true
autoconfigure: true
bind:
$container: '@service_container'
cleverage_process.command.execute_process:
class: CleverAge\ProcessBundle\Command\ExecuteProcessCommand
public: false
tags:
- { name: console.command }
arguments:
- '@process_bundle.manager.process'
- '@event_dispatcher'
- '@process_bundle.registry.process_configuration'

cleverage_process.command.list_process:
class: CleverAge\ProcessBundle\Command\ListProcessCommand
public: false
tags:
- { name: console.command }
arguments:
- '@process_bundle.registry.process_configuration'

cleverage_process.command.process_help:
class: CleverAge\ProcessBundle\Command\ProcessHelpCommand
public: false
tags:
- { name: console.command }
arguments:
- '@process_bundle.registry.process_configuration'
- '@service_container'
3 changes: 2 additions & 1 deletion config/services/event.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
CleverAge\ProcessBundle\EventListener\DataQueueEventListener:
cleverage_process.event_listener.data_queue:
class: CleverAge\ProcessBundle\EventListener\DataQueueEventListener
public: false
tags:
- { name: kernel.event_listener, event: cleverage_process.data_queue, method: pushData }
7 changes: 5 additions & 2 deletions config/services/expression_language.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
services:
CleverAge\ProcessBundle\ExpressionLanguage\PhpFunctionProvider:
cleverage_process.expression_language.php_function_provider:
class: CleverAge\ProcessBundle\ExpressionLanguage\PhpFunctionProvider
public: false
arguments:
- [ 'preg_match' ]

cleverage_process.expression_language:
class: Symfony\Component\ExpressionLanguage\ExpressionLanguage
public: false
calls:
- ['registerProvider', ['@CleverAge\ProcessBundle\ExpressionLanguage\PhpFunctionProvider']]
- ['registerProvider', ['@cleverage_process.expression_language.php_function_provider']]
35 changes: 25 additions & 10 deletions config/services/logger.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
services:
CleverAge\ProcessBundle\Logger\ProcessProcessor:
autowire: true
cleverage_process.logger.process_processor:
class: CleverAge\ProcessBundle\Logger\ProcessProcessor
public: false
tags:
- { name: monolog.processor, channel: cleverage_process }
arguments:
- '@process_bundle.manager.process'

CleverAge\ProcessBundle\Logger\TaskProcessor:
autowire: true
cleverage_process.logger.task_processor:
class: CleverAge\ProcessBundle\Logger\TaskProcessor
public: false
tags:
- { name: monolog.processor, channel: cleverage_process_task }
arguments:
- '@process_bundle.manager.process'

CleverAge\ProcessBundle\Logger\TransformerProcessor:
autowire: true
cleverage_process.logger.transformer_processor:
class: CleverAge\ProcessBundle\Logger\TransformerProcessor
public: false
tags:
- { name: monolog.processor, channel: cleverage_process_transformer }
arguments:
- '@process_bundle.manager.process'

CleverAge\ProcessBundle\Logger\ProcessLogger:
autowire: true
cleverage_process.logger.process_logger:
class: CleverAge\ProcessBundle\Logger\ProcessLogger
public: false
tags:
- { name: monolog.logger, channel: cleverage_process }
arguments:
- '@monolog.logger'

CleverAge\ProcessBundle\Logger\TaskLogger:
autowire: true
cleverage_process.logger.task_logger:
class: CleverAge\ProcessBundle\Logger\TaskLogger
public: false
tags:
- { name: monolog.logger, channel: cleverage_process_task }
arguments:
- '@monolog.logger'
14 changes: 10 additions & 4 deletions config/services/manager.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
services:
CleverAge\ProcessBundle\Manager\ProcessManager:
autowire: true
process_bundle.manager.process:
class: CleverAge\ProcessBundle\Manager\ProcessManager
public: false
arguments:
$container: '@service_container'
- '@service_container'
- '@cleverage_process.logger.process_logger'
- '@cleverage_process.logger.task_logger'
- '@process_bundle.registry.process_configuration'
- '@process_bundle.context.contextual_option_resolver'
- '@event_dispatcher'

CleverAge\ProcessBundle\Context\ContextualOptionResolver:
process_bundle.context.contextual_option_resolver:
class: CleverAge\ProcessBundle\Context\ContextualOptionResolver
public: false
7 changes: 5 additions & 2 deletions config/services/registry.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
services:
CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry:
process_bundle.registry.process_configuration:
class: CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry
public: false
arguments:
- ~
- ~

CleverAge\ProcessBundle\Registry\TransformerRegistry:
process_bundle.registry.transformer:
class: CleverAge\ProcessBundle\Registry\TransformerRegistry
public: false
8 changes: 7 additions & 1 deletion config/services/task.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
services:
_defaults:
bind:
$processManager: '@process_bundle.manager.process'
$processRegistry: '@process_bundle.registry.process_configuration'
$transformerRegistry: '@process_bundle.registry.transformer'

CleverAge\ProcessBundle\Task\:
resource: '../../../Task/*'
resource: '../../src/Task/*'
autowire: true
public: true
shared: false
Expand Down
11 changes: 6 additions & 5 deletions config/services/transformer.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: true
bind:
$language: '@cleverage_process.expression_language'
$transformerRegistry: '@process_bundle.registry.transformer'

CleverAge\ProcessBundle\Transformer\:
resource: '../../../Transformer/*'
exclude: '../../../Transformer/GenericTransformer.php'
resource: '../../src/Transformer/*'
exclude: '../../src/Transformer/GenericTransformer.php'
autowire: true
autoconfigure: true
public: true
tags:
- { name: cleverage.transformer }
- { name: monolog.logger, channel: cleverage_process_transformer }
2 changes: 1 addition & 1 deletion src/DependencyInjection/CleverAgeProcessExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$processConfigurationRegistry = $container->getDefinition(ProcessConfigurationRegistry::class);
$processConfigurationRegistry = $container->getDefinition('process_bundle.registry.process_configuration');
$processConfigurationRegistry->replaceArgument(0, $config['configurations']);
$processConfigurationRegistry->replaceArgument(1, $config['default_error_strategy']);

Expand Down

0 comments on commit 719c9ee

Please sign in to comment.