function Renderer::__construct

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::__construct()
  2. 8.9.x core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::__construct()
  3. 11.x core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::__construct()

Constructs a new Renderer.

Parameters

\Drupal\Core\Utility\CallableResolver|\Drupal\Core\Controller\ControllerResolverInterface $callable_resolver: The callable resolver.

\Drupal\Core\Theme\ThemeManagerInterface $theme: The theme manager.

\Drupal\Core\Render\ElementInfoManagerInterface $element_info: The element info.

\Drupal\Core\Render\PlaceholderGeneratorInterface $placeholder_generator: The placeholder generator.

\Drupal\Core\Render\RenderCacheInterface $render_cache: The render cache service.

\Symfony\Component\HttpFoundation\RequestStack $request_stack: The request stack.

array $renderer_config: The renderer configuration array.

File

core/lib/Drupal/Core/Render/Renderer.php, line 118

Class

Renderer
Turns a render array into an HTML string.

Namespace

Drupal\Core\Render

Code

public function __construct(ControllerResolverInterface|CallableResolver $callable_resolver, ThemeManagerInterface $theme, ElementInfoManagerInterface $element_info, PlaceholderGeneratorInterface $placeholder_generator, RenderCacheInterface $render_cache, RequestStack $request_stack, array $renderer_config) {
    if ($callable_resolver instanceof ControllerResolverInterface) {
        @trigger_error('Calling ' . __METHOD__ . '() with an argument of ControllerResolverInterface is deprecated in drupal:10.2.0 and is removed in drupal:11.0.0. Use \\Drupal\\Core\\Utility\\CallableResolver instead. See https://www.drupal.org/node/3369969', E_USER_DEPRECATED);
        $callable_resolver = \Drupal::service('callable_resolver');
    }
    $this->callableResolver = $callable_resolver;
    $this->theme = $theme;
    $this->elementInfo = $element_info;
    $this->placeholderGenerator = $placeholder_generator;
    $this->renderCache = $render_cache;
    if (!isset($renderer_config['debug'])) {
        $renderer_config['debug'] = FALSE;
    }
    $this->rendererConfig = $renderer_config;
    $this->requestStack = $request_stack;
    // Initialize the context collection if needed.
    if (!isset(static::$contextCollection)) {
        static::$contextCollection = new \SplObjectStorage();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.