services9.php 4.9 KB

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