services_interfaces-1.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. return $this->services['foo'] = new $class();
  35. $this->applyInterfaceInjectors($instance);
  36. }
  37. /**
  38. * Gets the default parameters.
  39. *
  40. * @return array An array of the default parameters
  41. */
  42. protected function getDefaultParameters()
  43. {
  44. return array(
  45. 'cla' => 'Fo',
  46. 'ss' => 'Class',
  47. );
  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 \FooClass) {
  57. $instance->setBar('someValue');
  58. }
  59. }
  60. }