You are here

class ClosureLoader in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php \Symfony\Component\DependencyInjection\Loader\ClosureLoader

ClosureLoader loads service definitions from a PHP closure.

The Closure has access to the container as its first argument.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

  • class \Symfony\Component\DependencyInjection\Loader\ClosureLoader extends \Symfony\Component\Config\Loader\Loader

Expanded class hierarchy of ClosureLoader

2 files declare their use of ClosureLoader
ClosureLoaderTest.php in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php
ContainerBuilderTest.php in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php, line 24

Namespace

Symfony\Component\DependencyInjection\Loader
View source
class ClosureLoader extends Loader {
  private $container;

  /**
   * Constructor.
   *
   * @param ContainerBuilder $container A ContainerBuilder instance
   */
  public function __construct(ContainerBuilder $container) {
    $this->container = $container;
  }

  /**
   * {@inheritdoc}
   */
  public function load($resource, $type = null) {
    call_user_func($resource, $this->container);
  }

  /**
   * {@inheritdoc}
   */
  public function supports($resource, $type = null) {
    return $resource instanceof \Closure;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ClosureLoader::$container private property
ClosureLoader::load public function
ClosureLoader::supports public function
ClosureLoader::__construct public function Constructor.