services_interfaces-2.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 'bar' service.
  25. *
  26. * This service is shared.
  27. * This method always returns the same instance of the service.
  28. *
  29. * @return Object An instance returned by barFactory::createBarClass().
  30. */
  31. protected function getBarService()
  32. {
  33. return $this->services['bar'] = $this->get('barFactory')->createBarClass();
  34. $this->applyInterfaceInjectors($instance);
  35. }
  36. /**
  37. * Gets the 'barfactory' service.
  38. *
  39. * This service is shared.
  40. * This method always returns the same instance of the service.
  41. *
  42. * @return BarClassFactory A BarClassFactory instance.
  43. */
  44. protected function getBarfactoryService()
  45. {
  46. return $this->services['barfactory'] = new \BarClassFactory();
  47. $this->applyInterfaceInjectors($instance);
  48. }
  49. /**
  50. * Applies all known interface injection calls
  51. *
  52. * @param Object $instance
  53. */
  54. protected function applyInterfaceInjectors($instance)
  55. {
  56. if ($instance instanceof \BarClass) {
  57. $instance->setFoo('someValue');
  58. }
  59. }
  60. }