You are here

class LazyLoadingFragmentHandler in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php \Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler

Lazily loads fragment renderers from the dependency injection container.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of LazyLoadingFragmentHandler

1 file declares its use of LazyLoadingFragmentHandler
LazyLoadingFragmentHandlerTest.php in vendor/symfony/http-kernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php

File

vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php, line 23

Namespace

Symfony\Component\HttpKernel\DependencyInjection
View source
class LazyLoadingFragmentHandler extends FragmentHandler {
  private $container;
  private $rendererIds = array();
  public function __construct(ContainerInterface $container, $debug = false, RequestStack $requestStack = null) {
    $this->container = $container;
    parent::__construct(array(), $debug, $requestStack);
  }

  /**
   * Adds a service as a fragment renderer.
   *
   * @param string $renderer The render service id
   */
  public function addRendererService($name, $renderer) {
    $this->rendererIds[$name] = $renderer;
  }

  /**
   * {@inheritdoc}
   */
  public function render($uri, $renderer = 'inline', array $options = array()) {
    if (isset($this->rendererIds[$renderer])) {
      $this
        ->addRenderer($this->container
        ->get($this->rendererIds[$renderer]));
      unset($this->rendererIds[$renderer]);
    }
    return parent::render($uri, $renderer, $options);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FragmentHandler::$debug private property
FragmentHandler::$renderers private property
FragmentHandler::$request private property
FragmentHandler::$requestStack private property
FragmentHandler::addRenderer public function Adds a renderer.
FragmentHandler::deliver protected function Delivers the Response as a string.
FragmentHandler::getRequest private function
FragmentHandler::setRequest Deprecated public function Sets the current Request.
LazyLoadingFragmentHandler::$container private property
LazyLoadingFragmentHandler::$rendererIds private property
LazyLoadingFragmentHandler::addRendererService public function Adds a service as a fragment renderer.
LazyLoadingFragmentHandler::render public function Renders a URI and returns the Response content. Overrides FragmentHandler::render
LazyLoadingFragmentHandler::__construct public function Constructor. Overrides FragmentHandler::__construct