You are here

protected function ProjectServiceContainer::getMethodCall1Service in Service Container 7.2

Same name in this branch
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php \ProjectServiceContainer::getMethodCall1Service()
  2. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php \ProjectServiceContainer::getMethodCall1Service()
Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php \ProjectServiceContainer::getMethodCall1Service()
  2. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php \ProjectServiceContainer::getMethodCall1Service()

Gets the 'method_call1' service.

This service is shared. This method always returns the same instance of the service.

Return value

\Bar\FooClass A Bar\FooClass instance.

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php, line 237

Class

ProjectServiceContainer
ProjectServiceContainer.

Code

protected function getMethodCall1Service() {
  require_once '%path%foo.php';
  $this->services['method_call1'] = $instance = new \Bar\FooClass();
  $instance
    ->setBar($this
    ->get('foo'));
  $instance
    ->setBar($this
    ->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  if ($this
    ->has('foo3')) {
    $instance
      ->setBar($this
      ->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  }
  if ($this
    ->has('foobaz')) {
    $instance
      ->setBar($this
      ->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
  }
  $instance
    ->setBar($this
    ->get("foo")
    ->foo() . ($this
    ->hasparameter("foo") ? $this
    ->getParameter("foo") : "default"));
  return $instance;
}