services9.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. use Symfony\Components\DependencyInjection\ContainerInterface;
  3. use Symfony\Components\DependencyInjection\Container;
  4. use Symfony\Components\DependencyInjection\Reference;
  5. use Symfony\Components\DependencyInjection\Parameter;
  6. use Symfony\Components\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. protected $shared = array();
  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. * @return FooClass A FooClass instance.
  27. */
  28. protected function getFooService()
  29. {
  30. require_once '%path%foo.php';
  31. $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $this->getFoo_BazService(), array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo'), 'bar' => $this->getParameter('foo')), true, $this);
  32. $instance->setBar('bar');
  33. $instance->initialize();
  34. sc_configure($instance);
  35. return $instance;
  36. }
  37. /**
  38. * Gets the 'bar' service.
  39. *
  40. * This service is shared.
  41. * This method always returns the same instance of the service.
  42. *
  43. * @return FooClass A FooClass instance.
  44. */
  45. protected function getBarService()
  46. {
  47. if (isset($this->shared['bar'])) return $this->shared['bar'];
  48. $instance = new FooClass('foo', $this->getFoo_BazService(), $this->getParameter('foo_bar'));
  49. $this->shared['bar'] = $instance;
  50. $this->getFoo_BazService()->configure($instance);
  51. return $instance;
  52. }
  53. /**
  54. * Gets the 'foo.baz' service.
  55. *
  56. * This service is shared.
  57. * This method always returns the same instance of the service.
  58. *
  59. * @return Object A %baz_class% instance.
  60. */
  61. protected function getFoo_BazService()
  62. {
  63. if (isset($this->shared['foo.baz'])) return $this->shared['foo.baz'];
  64. $instance = call_user_func(array($this->getParameter('baz_class'), 'getInstance'));
  65. $this->shared['foo.baz'] = $instance;
  66. call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance);
  67. return $instance;
  68. }
  69. /**
  70. * Gets the 'foo_bar' service.
  71. *
  72. * This service is shared.
  73. * This method always returns the same instance of the service.
  74. *
  75. * @return Object A %foo_class% instance.
  76. */
  77. protected function getFooBarService()
  78. {
  79. if (isset($this->shared['foo_bar'])) return $this->shared['foo_bar'];
  80. $class = $this->getParameter('foo_class');
  81. $instance = new $class();
  82. $this->shared['foo_bar'] = $instance;
  83. return $instance;
  84. }
  85. /**
  86. * Gets the 'method_call1' service.
  87. *
  88. * This service is shared.
  89. * This method always returns the same instance of the service.
  90. *
  91. * @return FooClass A FooClass instance.
  92. */
  93. protected function getMethodCall1Service()
  94. {
  95. if (isset($this->shared['method_call1'])) return $this->shared['method_call1'];
  96. $instance = new FooClass();
  97. $this->shared['method_call1'] = $instance;
  98. $instance->setBar($this->getFooService());
  99. $instance->setBar($this->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  100. if ($this->has('foo')) {
  101. $instance->setBar($this->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  102. }
  103. if ($this->has('foobaz')) {
  104. $instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  105. }
  106. return $instance;
  107. }
  108. /**
  109. * Gets the 'factory_service' service.
  110. *
  111. * This service is shared.
  112. * This method always returns the same instance of the service.
  113. *
  114. * @return Object An instance returned by foo.baz::getInstance().
  115. */
  116. protected function getFactoryServiceService()
  117. {
  118. if (isset($this->shared['factory_service'])) return $this->shared['factory_service'];
  119. $instance = $this->getFoo_BazService()->getInstance();
  120. $this->shared['factory_service'] = $instance;
  121. return $instance;
  122. }
  123. /**
  124. * Gets the alias_for_foo service alias.
  125. *
  126. * @return FooClass An instance of the foo service
  127. */
  128. protected function getAliasForFooService()
  129. {
  130. return $this->getFooService();
  131. }
  132. /**
  133. * Returns service ids for a given tag.
  134. *
  135. * @param string $name The tag name
  136. *
  137. * @return array An array of tags
  138. */
  139. public function findTaggedServiceIds($name)
  140. {
  141. static $tags = array (
  142. 'foo' =>
  143. array (
  144. 'foo' =>
  145. array (
  146. 0 =>
  147. array (
  148. 'foo' => 'foo',
  149. ),
  150. 1 =>
  151. array (
  152. 'bar' => 'bar',
  153. ),
  154. ),
  155. ),
  156. );
  157. return isset($tags[$name]) ? $tags[$name] : array();
  158. }
  159. /**
  160. * Gets the default parameters.
  161. *
  162. * @return array An array of the default parameters
  163. */
  164. protected function getDefaultParameters()
  165. {
  166. return array(
  167. 'baz_class' => 'BazClass',
  168. 'foo_class' => 'FooClass',
  169. 'foo' => 'bar',
  170. );
  171. }
  172. }