ProjectExtension.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use Symfony\Component\DependencyInjection\ContainerBuilder;
  3. use Symfony\Component\DependencyInjection\Definition;
  4. use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  5. class ProjectExtension implements ExtensionInterface
  6. {
  7. public function load(array $configs, ContainerBuilder $configuration)
  8. {
  9. $configuration->setParameter('project.configs', $configs);
  10. $configs = array_filter($configs);
  11. if ($configs) {
  12. $config = call_user_func_array('array_merge', $configs);
  13. } else {
  14. $config = array();
  15. }
  16. $configuration->setDefinition('project.service.bar', new Definition('FooClass'));
  17. $configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');
  18. $configuration->setDefinition('project.service.foo', new Definition('FooClass'));
  19. $configuration->setParameter('project.parameter.foo', isset($config['foo']) ? $config['foo'] : 'foobar');
  20. return $configuration;
  21. }
  22. public function getXsdValidationBasePath()
  23. {
  24. return false;
  25. }
  26. public function getNamespace()
  27. {
  28. return 'http://www.example.com/schema/project';
  29. }
  30. public function getAlias()
  31. {
  32. return 'project';
  33. }
  34. public function getConfiguration(array $config, ContainerBuilder $container)
  35. {
  36. }
  37. }