services9.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. use Symfony\Components\DependencyInjection\Container;
  3. use Symfony\Components\DependencyInjection\Reference;
  4. use Symfony\Components\DependencyInjection\Parameter;
  5. /**
  6. * ProjectServiceContainer
  7. *
  8. * This class has been auto-generated
  9. * by the Symfony Dependency Injection Component.
  10. *
  11. * @property FooClass $foo
  12. * @property FooClass $bar
  13. * @property Object $foo.baz
  14. * @property Object $foo_bar
  15. * @property FooClass $method_call1
  16. * @property FooClass $alias_for_foo
  17. */
  18. class ProjectServiceContainer extends Container
  19. {
  20. protected $shared = array();
  21. /**
  22. * Constructor.
  23. */
  24. public function __construct()
  25. {
  26. parent::__construct($this->getDefaultParameters());
  27. }
  28. /**
  29. * Gets the 'foo' service.
  30. *
  31. * @return FooClass A FooClass instance.
  32. */
  33. protected function getFooService()
  34. {
  35. require_once '%path%/foo.php';
  36. $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $this->getService('foo.baz'), array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo'), 'bar' => $this->getParameter('foo')), true, $this);
  37. $instance->setBar('bar');
  38. $instance->initialize();
  39. sc_configure($instance);
  40. return $instance;
  41. }
  42. /**
  43. * Gets the 'bar' service.
  44. *
  45. * This service is shared.
  46. * This method always returns the same instance of the service.
  47. *
  48. * @return FooClass A FooClass instance.
  49. */
  50. protected function getBarService()
  51. {
  52. if (isset($this->shared['bar'])) return $this->shared['bar'];
  53. $instance = new FooClass('foo', $this->getService('foo.baz'), $this->getParameter('foo_bar'));
  54. $this->getService('foo.baz')->configure($instance);
  55. return $this->shared['bar'] = $instance;
  56. }
  57. /**
  58. * Gets the 'foo.baz' service.
  59. *
  60. * This service is shared.
  61. * This method always returns the same instance of the service.
  62. *
  63. * @return Object A %baz_class% instance.
  64. */
  65. protected function getFoo_BazService()
  66. {
  67. if (isset($this->shared['foo.baz'])) return $this->shared['foo.baz'];
  68. $instance = call_user_func(array($this->getParameter('baz_class'), 'getInstance'));
  69. call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance);
  70. return $this->shared['foo.baz'] = $instance;
  71. }
  72. /**
  73. * Gets the 'foo_bar' service.
  74. *
  75. * This service is shared.
  76. * This method always returns the same instance of the service.
  77. *
  78. * @return Object A %foo_class% instance.
  79. */
  80. protected function getFooBarService()
  81. {
  82. if (isset($this->shared['foo_bar'])) return $this->shared['foo_bar'];
  83. $class = $this->getParameter('foo_class');
  84. $instance = new $class();
  85. return $this->shared['foo_bar'] = $instance;
  86. }
  87. /**
  88. * Gets the 'method_call1' service.
  89. *
  90. * This service is shared.
  91. * This method always returns the same instance of the service.
  92. *
  93. * @return FooClass A FooClass instance.
  94. */
  95. protected function getMethodCall1Service()
  96. {
  97. if (isset($this->shared['method_call1'])) return $this->shared['method_call1'];
  98. $instance = new FooClass();
  99. $instance->setBar($this->getService('foo'));
  100. $instance->setBar($this->getService('foo', Container::NULL_ON_INVALID_REFERENCE));
  101. if ($this->hasService('foo'))
  102. {
  103. $instance->setBar($this->getService('foo', Container::NULL_ON_INVALID_REFERENCE));
  104. }
  105. if ($this->hasService('foobaz'))
  106. {
  107. $instance->setBar($this->getService('foobaz', Container::NULL_ON_INVALID_REFERENCE));
  108. }
  109. return $this->shared['method_call1'] = $instance;
  110. }
  111. /**
  112. * Gets the alias_for_foo service alias.
  113. *
  114. * @return FooClass An instance of the foo service
  115. */
  116. protected function getAliasForFooService()
  117. {
  118. return $this->getService('foo');
  119. }
  120. /**
  121. * Gets the default parameters.
  122. *
  123. * @return array An array of the default parameters
  124. */
  125. protected function getDefaultParameters()
  126. {
  127. return array(
  128. 'baz_class' => 'BazClass',
  129. 'foo_class' => 'FooClass',
  130. 'foo' => 'bar',
  131. );
  132. }
  133. }