services_interfaces-2.php 1.7 KB

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