services9.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. use Symfony\Component\DependencyInjection\ContainerInterface;
  3. use Symfony\Component\DependencyInjection\TaggedContainerInterface;
  4. use Symfony\Component\DependencyInjection\Container;
  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 implements TaggedContainerInterface
  15. {
  16. protected $shared = array();
  17. /**
  18. * Constructor.
  19. */
  20. public function __construct()
  21. {
  22. parent::__construct(new ParameterBag($this->getDefaultParameters()));
  23. }
  24. /**
  25. * Gets the 'foo' service.
  26. *
  27. * @return FooClass A FooClass instance.
  28. */
  29. protected function getFooService()
  30. {
  31. $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $this->get('foo.baz'), array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo'), 'bar' => $this->getParameter('foo')), true, $this);
  32. $instance->setBar($this->get('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->get('foo.baz'), $this->getParameter('foo_bar'));
  49. $this->shared['bar'] = $instance;
  50. $this->get('foo.baz')->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. require_once '%path%foo.php';
  96. if (isset($this->shared['method_call1'])) return $this->shared['method_call1'];
  97. $instance = new FooClass();
  98. $this->shared['method_call1'] = $instance;
  99. $instance->setBar($this->get('foo'));
  100. $instance->setBar($this->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  101. if ($this->has('foo')) {
  102. $instance->setBar($this->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  103. }
  104. if ($this->has('foobaz')) {
  105. $instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  106. }
  107. return $instance;
  108. }
  109. /**
  110. * Gets the 'factory_service' service.
  111. *
  112. * This service is shared.
  113. * This method always returns the same instance of the service.
  114. *
  115. * @return Object An instance returned by foo.baz::getInstance().
  116. */
  117. protected function getFactoryServiceService()
  118. {
  119. if (isset($this->shared['factory_service'])) return $this->shared['factory_service'];
  120. $instance = $this->get('foo.baz')->getInstance();
  121. $this->shared['factory_service'] = $instance;
  122. return $instance;
  123. }
  124. /**
  125. * Gets the alias_for_foo service alias.
  126. *
  127. * @return FooClass An instance of the foo service
  128. */
  129. protected function getAliasForFooService()
  130. {
  131. return $this->get('foo');
  132. }
  133. /**
  134. * Returns service ids for a given tag.
  135. *
  136. * @param string $name The tag name
  137. *
  138. * @return array An array of tags
  139. */
  140. public function findTaggedServiceIds($name)
  141. {
  142. static $tags = array (
  143. 'foo' =>
  144. array (
  145. 'foo' =>
  146. array (
  147. 0 =>
  148. array (
  149. 'foo' => 'foo',
  150. ),
  151. 1 =>
  152. array (
  153. 'bar' => 'bar',
  154. ),
  155. ),
  156. ),
  157. );
  158. return isset($tags[$name]) ? $tags[$name] : array();
  159. }
  160. /**
  161. * Gets the default parameters.
  162. *
  163. * @return array An array of the default parameters
  164. */
  165. protected function getDefaultParameters()
  166. {
  167. return array(
  168. 'baz_class' => 'BazClass',
  169. 'foo_class' => 'FooClass',
  170. 'foo' => 'bar',
  171. );
  172. }
  173. }