GearmanExtension.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Gearman Bundle for Symfony2
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * Feel free to edit as you please, and have fun.
  9. *
  10. * @author Marc Morera <yuhu@mmoreram.com>
  11. */
  12. namespace Mmoreram\GearmanBundle\DependencyInjection;
  13. use Symfony\Component\Config\FileLocator;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  16. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  17. /**
  18. * This is the class that loads and manages your bundle configuration
  19. *
  20. * @since 2.3.1
  21. */
  22. class GearmanExtension extends Extension
  23. {
  24. /**
  25. * Loads a specific configuration.
  26. *
  27. * @param array $config An array of configuration values
  28. * @param ContainerBuilder $container A ContainerBuilder instance
  29. *
  30. * @throws \InvalidArgumentException When provided tag is not defined in this extension
  31. *
  32. * @api
  33. */
  34. public function load(array $config, ContainerBuilder $container)
  35. {
  36. $configuration = new Configuration();
  37. $config = $this->processConfiguration($configuration, $config);
  38. /**
  39. * Setting all config elements as DI parameters to inject them
  40. */
  41. $container->setParameter(
  42. 'gearman.bundles',
  43. $config['bundles']
  44. );
  45. $container->setParameter(
  46. 'gearman.servers',
  47. $config['servers']
  48. );
  49. $container->setParameter(
  50. 'gearman.default.settings',
  51. $config['defaults']
  52. );
  53. $container->setParameter(
  54. 'gearman.default.settings.generate_unique_key',
  55. $config['defaults']['generate_unique_key']
  56. );
  57. $loader = new YamlFileLoader(
  58. $container,
  59. new FileLocator(__DIR__ . '/../Resources/config')
  60. );
  61. /**
  62. * Loading DI definitions
  63. */
  64. $loader->load('classes.yml');
  65. $loader->load('services.yml');
  66. $loader->load('commands.yml');
  67. $loader->load('eventDispatchers.yml');
  68. $loader->load('generators.yml');
  69. $loader->load('externals.yml');
  70. }
  71. }