services_interfaces-2.php 1.8 KB

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