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. require_once '%path%foo.php';
  32. $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);
  33. $instance->setBar('bar');
  34. $instance->initialize();
  35. sc_configure($instance);
  36. return $instance;
  37. }
  38. /**
  39. * Gets the 'bar' service.
  40. *
  41. * This service is shared.
  42. * This method always returns the same instance of the service.
  43. *
  44. * @return FooClass A FooClass instance.
  45. */
  46. protected function getBarService()
  47. {
  48. if (isset($this->shared['bar'])) return $this->shared['bar'];
  49. $instance = new FooClass('foo', $this->getFoo_BazService(), $this->getParameter('foo_bar'));
  50. $this->shared['bar'] = $instance;
  51. $this->getFoo_BazService()->configure($instance);
  52. return $instance;
  53. }
  54. /**
  55. * Gets the 'foo.baz' service.
  56. *
  57. * This service is shared.
  58. * This method always returns the same instance of the service.
  59. *
  60. * @return Object A %baz_class% instance.
  61. */
  62. protected function getFoo_BazService()
  63. {
  64. if (isset($this->shared['foo.baz'])) return $this->shared['foo.baz'];
  65. $instance = call_user_func(array($this->getParameter('baz_class'), 'getInstance'));
  66. $this->shared['foo.baz'] = $instance;
  67. call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance);
  68. return $instance;
  69. }
  70. /**
  71. * Gets the 'foo_bar' service.
  72. *
  73. * This service is shared.
  74. * This method always returns the same instance of the service.
  75. *
  76. * @return Object A %foo_class% instance.
  77. */
  78. protected function getFooBarService()
  79. {
  80. if (isset($this->shared['foo_bar'])) return $this->shared['foo_bar'];
  81. $class = $this->getParameter('foo_class');
  82. $instance = new $class();
  83. $this->shared['foo_bar'] = $instance;
  84. return $instance;
  85. }
  86. /**
  87. * Gets the 'method_call1' service.
  88. *
  89. * This service is shared.
  90. * This method always returns the same instance of the service.
  91. *
  92. * @return FooClass A FooClass instance.
  93. */
  94. protected function getMethodCall1Service()
  95. {
  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->getFooService());
  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->getFoo_BazService()->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->getFooService();
  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. }