services_interfaces-1.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 'foo' service.
  24. *
  25. * This service is shared.
  26. * This method always returns the same instance of the service.
  27. *
  28. * @return Object A %cla%o%ss% instance.
  29. */
  30. protected function getFooService()
  31. {
  32. $class = $this->getParameter('cla').'o'.$this->getParameter('ss');
  33. return $this->services['foo'] = new $class();
  34. $this->applyInterfaceInjectors($instance);
  35. }
  36. /**
  37. * Gets the default parameters.
  38. *
  39. * @return array An array of the default parameters
  40. */
  41. protected function getDefaultParameters()
  42. {
  43. return array(
  44. 'cla' => 'Fo',
  45. 'ss' => 'Class',
  46. );
  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 \FooClass) {
  56. $instance->setBar('someValue');
  57. }
  58. }
  59. }