services9.php 4.5 KB

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