mmucklo /
DtcQueueBundle
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Dtc\QueueBundle\DependencyInjection\Compiler; |
||
| 4 | |||
| 5 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Depend...ection\ContainerBuilder was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 7 | use Symfony\Component\DependencyInjection\Definition; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\DependencyInjection\Definition was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 8 | use Symfony\Component\DependencyInjection\Reference; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\DependencyInjection\Reference was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 9 | |||
| 10 | class RabbitMQCompilerPass implements CompilerPassInterface |
||
| 11 | { |
||
| 12 | 1 | public function process(ContainerBuilder $container): void |
|
| 13 | { |
||
| 14 | 1 | if ($container->hasParameter('dtc_queue.rabbit_mq') && |
|
| 15 | 1 | $container->getParameter('dtc_queue.rabbit_mq')) { |
|
| 16 | 1 | $class = 'PhpAmqpLib\\Connection\\AMQPStreamConnection'; |
|
| 17 | 1 | $rabbitMqConfig = $container->getParameter('dtc_queue.rabbit_mq'); |
|
| 18 | $arguments = [ |
||
| 19 | 1 | $rabbitMqConfig['host'], |
|
| 20 | 1 | $rabbitMqConfig['port'], |
|
| 21 | 1 | $rabbitMqConfig['user'], |
|
| 22 | 1 | $rabbitMqConfig['password'], |
|
| 23 | 1 | $rabbitMqConfig['vhost'], |
|
| 24 | ]; |
||
| 25 | |||
| 26 | 1 | $this->setupRabbitMQOptions($container, $arguments, $class); |
|
| 27 | 1 | $definition = new Definition($class, $arguments); |
|
| 28 | 1 | $container->setDefinition('dtc_queue.rabbit_mq', $definition); |
|
| 29 | 1 | $definition = $container->getDefinition('dtc_queue.manager.job.rabbit_mq'); |
|
| 30 | 1 | $definition->addMethodCall('setAMQPConnection', [new Reference('dtc_queue.rabbit_mq')]); |
|
| 31 | 1 | $definition->addMethodCall('setQueueArgs', array_values($rabbitMqConfig['queue_args'])); |
|
| 32 | 1 | $definition->addMethodCall('setExchangeArgs', array_values($rabbitMqConfig['exchange_args'])); |
|
| 33 | } |
||
| 34 | 1 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @param string $class |
||
| 38 | */ |
||
| 39 | 1 | protected function setupRabbitMQOptions(ContainerBuilder $container, array &$arguments, &$class) |
|
| 40 | { |
||
| 41 | 1 | $rabbitMqConfig = $container->getParameter('dtc_queue.rabbit_mq'); |
|
| 42 | 1 | if (isset($rabbitMqConfig['ssl']) && $rabbitMqConfig['ssl']) { |
|
| 43 | 1 | $class = 'PhpAmqpLib\\Connection\\AMQPSSLConnection'; |
|
| 44 | 1 | if (!empty($rabbitMqConfig['ssl_options'])) { |
|
| 45 | 1 | $arguments[] = $rabbitMqConfig['ssl_options']; |
|
| 46 | } else { |
||
| 47 | 1 | $arguments[] = []; |
|
| 48 | } |
||
| 49 | 1 | if (!empty($rabbitMqConfig['options'])) { |
|
| 50 | 1 | $arguments[] = $rabbitMqConfig['options']; |
|
| 51 | } |
||
| 52 | } else { |
||
| 53 | 1 | if (!empty($rabbitMqConfig['options'])) { |
|
| 54 | 1 | $options = $rabbitMqConfig['options']; |
|
| 55 | 1 | $this->setRabbitMqOptionsPt1($arguments, $options); |
|
| 56 | 1 | $this->setRabbitMqOptionsPt2($arguments, $options); |
|
| 57 | } |
||
| 58 | } |
||
| 59 | 1 | } |
|
| 60 | |||
| 61 | 1 | protected function setRabbitMqOptionsPt1(array &$arguments, array $options) |
|
| 62 | { |
||
| 63 | 1 | if (isset($options['insist'])) { |
|
| 64 | 1 | $arguments[] = $options['insist']; |
|
| 65 | } else { |
||
| 66 | $arguments[] = false; |
||
| 67 | } |
||
| 68 | 1 | if (isset($options['login_method'])) { |
|
| 69 | $arguments[] = $options['login_method']; |
||
| 70 | } else { |
||
| 71 | 1 | $arguments[] = 'AMQPLAIN'; |
|
| 72 | } |
||
| 73 | 1 | if (isset($options['login_response'])) { |
|
| 74 | $arguments[] = $options['login_response']; |
||
| 75 | } else { |
||
| 76 | 1 | $arguments[] = null; |
|
| 77 | } |
||
| 78 | 1 | if (isset($options['locale'])) { |
|
| 79 | $arguments[] = $options['locale']; |
||
| 80 | } else { |
||
| 81 | 1 | $arguments[] = 'en_US'; |
|
| 82 | } |
||
| 83 | 1 | } |
|
| 84 | |||
| 85 | 1 | protected function setRabbitMqOptionsPt2(array &$arguments, array $options) |
|
| 86 | { |
||
| 87 | 1 | if (isset($options['connection_timeout'])) { |
|
| 88 | $arguments[] = $options['connection_timeout']; |
||
| 89 | } else { |
||
| 90 | 1 | $arguments[] = 3.0; |
|
| 91 | } |
||
| 92 | 1 | if (isset($options['read_write_timeout'])) { |
|
| 93 | $arguments[] = $options['read_write_timeout']; |
||
| 94 | } else { |
||
| 95 | 1 | $arguments[] = 3.0; |
|
| 96 | } |
||
| 97 | |||
| 98 | // Context is impossible to set through config.yml |
||
| 99 | 1 | $arguments[] = null; |
|
| 100 | |||
| 101 | 1 | if (isset($options['keepalive'])) { |
|
| 102 | $arguments[] = $options['keepalive']; |
||
| 103 | } else { |
||
| 104 | 1 | $arguments[] = false; |
|
| 105 | } |
||
| 106 | 1 | if (isset($options['heartbeat'])) { |
|
| 107 | $arguments[] = $options['heartbeat']; |
||
| 108 | } else { |
||
| 109 | 1 | $arguments[] = 0; |
|
| 110 | } |
||
| 111 | 1 | } |
|
| 112 | } |
||
| 113 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths