services9.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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->getFoo_BazService()->configure($instance);
  56. return $this->shared['bar'] = $instance;
  57. }
  58. /**
  59. * Gets the 'foo.baz' service.
  60. *
  61. * This service is shared.
  62. * This method always returns the same instance of the service.
  63. *
  64. * @return Object A %baz_class% instance.
  65. */
  66. protected function getFoo_BazService()
  67. {
  68. if (isset($this->shared['foo.baz'])) return $this->shared['foo.baz'];
  69. $instance = call_user_func(array($this->getParameter('baz_class'), 'getInstance'));
  70. call_user_func(array($this->getParameter('baz_class'), 'configureStatic1'), $instance);
  71. return $this->shared['foo.baz'] = $instance;
  72. }
  73. /**
  74. * Gets the 'foo_bar' service.
  75. *
  76. * This service is shared.
  77. * This method always returns the same instance of the service.
  78. *
  79. * @return Object A %foo_class% instance.
  80. */
  81. protected function getFooBarService()
  82. {
  83. if (isset($this->shared['foo_bar'])) return $this->shared['foo_bar'];
  84. $class = $this->getParameter('foo_class');
  85. $instance = new $class();
  86. return $this->shared['foo_bar'] = $instance;
  87. }
  88. /**
  89. * Gets the 'method_call1' service.
  90. *
  91. * This service is shared.
  92. * This method always returns the same instance of the service.
  93. *
  94. * @return FooClass A FooClass instance.
  95. */
  96. protected function getMethodCall1Service()
  97. {
  98. if (isset($this->shared['method_call1'])) return $this->shared['method_call1'];
  99. $instance = new FooClass();
  100. $instance->setBar($this->getFooService());
  101. $instance->setBar($this->getService('foo', Container::NULL_ON_INVALID_REFERENCE));
  102. if ($this->hasService('foo'))
  103. {
  104. $instance->setBar($this->getService('foo', Container::NULL_ON_INVALID_REFERENCE));
  105. }
  106. if ($this->hasService('foobaz'))
  107. {
  108. $instance->setBar($this->getService('foobaz', Container::NULL_ON_INVALID_REFERENCE));
  109. }
  110. return $this->shared['method_call1'] = $instance;
  111. }
  112. /**
  113. * Gets the alias_for_foo service alias.
  114. *
  115. * @return FooClass An instance of the foo service
  116. */
  117. protected function getAliasForFooService()
  118. {
  119. return $this->getFooService();
  120. }
  121. /**
  122. * Gets the default parameters.
  123. *
  124. * @return array An array of the default parameters
  125. */
  126. protected function getDefaultParameters()
  127. {
  128. return array(
  129. 'baz_class' => 'BazClass',
  130. 'foo_class' => 'FooClass',
  131. 'foo' => 'bar',
  132. );
  133. }
  134. }