services_interfaces-1.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. use Symfony\Component\DependencyInjection\ContainerInterface;
  3. use Symfony\Component\DependencyInjection\Container;
  4. use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
  5. use Symfony\Component\DependencyInjection\Reference;
  6. use Symfony\Component\DependencyInjection\Parameter;
  7. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
  8. /**
  9. * ProjectServiceContainer
  10. *
  11. * This class has been auto-generated
  12. * by the Symfony Dependency Injection Component.
  13. */
  14. class ProjectServiceContainer extends Container
  15. {
  16. /**
  17. * Constructor.
  18. */
  19. public function __construct()
  20. {
  21. parent::__construct(new ParameterBag($this->getDefaultParameters()));
  22. }
  23. /**
  24. * Gets the 'foo' service.
  25. *
  26. * This service is shared.
  27. * This method always returns the same instance of the service.
  28. *
  29. * @return Object A %cla%o%ss% instance.
  30. */
  31. protected function getFooService()
  32. {
  33. $class = $this->getParameter('cla').'o'.$this->getParameter('ss');
  34. $this->services['foo'] = $instance = new $class();
  35. $this->applyInterfaceInjectors($instance);
  36. return $instance;
  37. }
  38. /**
  39. * Gets the default parameters.
  40. *
  41. * @return array An array of the default parameters
  42. */
  43. protected function getDefaultParameters()
  44. {
  45. return array(
  46. 'cla' => 'Fo',
  47. 'ss' => 'Class',
  48. );
  49. }
  50. /**
  51. * Applies all known interface injection calls
  52. *
  53. * @param Object $instance
  54. */
  55. protected function applyInterfaceInjectors($instance)
  56. {
  57. if ($instance instanceof \FooClass) {
  58. $instance->setBar('someValue');
  59. }
  60. }
  61. }