| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Cmobi\RabbitmqBundle\DependencyInjection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Cmobi\RabbitmqBundle\DependencyInjection\Compiler\LogDispatcherPass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Cmobi\RabbitmqBundle\DependencyInjection\Compiler\RpcServerPass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Symfony\Component\Config\FileLocator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Symfony\Component\DependencyInjection\ContainerBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Symfony\Component\DependencyInjection\Definition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Symfony\Component\HttpKernel\DependencyInjection\Extension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | class CmobiRabbitmqExtension extends Extension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     public function load(array $configs, ContainerBuilder $container) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         $fileLocator = new FileLocator(__DIR__ . '/../Resources/config'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |         $loader = new YamlFileLoader($container, $fileLocator); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $loader->load('rabbitmq.yml'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $configuration = $this->getConfiguration($configs, $container); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $config = $this->processConfiguration($configuration, $configs); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $this->registerLogger($container, $configs[0]['log_path']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $this->loadConnections($container, $configs[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->loadRpcServers($container, $config); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         /* Compile and lock container */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $container->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |     protected function loadConnections(ContainerBuilder $container, array $configs) | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         $factories = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         foreach ($configs['connections'] as $name => $connection) { | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |             $connectionClass = '%cmobi_rabbitmq.connection.class%'; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |             if ($connection['lazy']) { | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |                 $connectionClass = '%cmobi_rabbitmq.lazy.connection.class%'; | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |             $definition = new Definition( | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |                 '%cmobi_rabbitmq.connection.factory.class%', | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |                 [ | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |                     $connectionClass, | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |                     $connection, | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |                 ] | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |             $factoryName = sprintf('cmobi_rabbitmq.connection.factory.%s', $name); | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |             $container->setDefinition($factoryName, $definition); | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |             $factories[$name] = $factoryName; | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         $container->setParameter('cmobi_rabbitmq.connection.factories', $factories); | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function loadRpcServers(ContainerBuilder $container, array $configs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         foreach ($configs['rpc_servers'] as $server) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             $container->addCompilerPass(new RpcServerPass( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 $server['queue']['name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 $server['queue']['connection'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                 $server['service'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                 $server['queue']['basic_qos'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                 $server['queue']['durable'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                 $server['queue']['auto_delete'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                 $server['queue']['arguments'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * @param ContainerBuilder $container | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * @param $path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     public function registerLogger(ContainerBuilder $container, $path) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $logDispatcherPass = new LogDispatcherPass($path); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $container->addCompilerPass($logDispatcherPass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 81 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 82 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: