function LayoutBuilder::__construct

Same name in other branches
  1. 8.9.x core/modules/layout_builder/src/Element/LayoutBuilder.php \Drupal\layout_builder\Element\LayoutBuilder::__construct()
  2. 10 core/modules/layout_builder/src/Element/LayoutBuilder.php \Drupal\layout_builder\Element\LayoutBuilder::__construct()
  3. 11.x core/modules/layout_builder/src/Element/LayoutBuilder.php \Drupal\layout_builder\Element\LayoutBuilder::__construct()

Constructs a new LayoutBuilder.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin ID for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

\Symfony\Contracts\EventDispatcher\EventDispatcherInterface $event_dispatcher: The event dispatcher service.

\Drupal\Core\Messenger\MessengerInterface|null $messenger: The messenger service. This is no longer used and will be removed in drupal:10.0.0.

File

core/modules/layout_builder/src/Element/LayoutBuilder.php, line 55

Class

LayoutBuilder
Defines a render element for building the Layout Builder UI.

Namespace

Drupal\layout_builder\Element

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, $event_dispatcher, $messenger = NULL) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    if (!$event_dispatcher instanceof EventDispatcherInterface) {
        @trigger_error('The event_dispatcher service should be passed to LayoutBuilder::__construct() instead of the layout_builder.tempstore_repository service since 9.1.0. This will be required in Drupal 10.0.0. See https://www.drupal.org/node/3152690', E_USER_DEPRECATED);
        $event_dispatcher = \Drupal::service('event_dispatcher');
    }
    $this->eventDispatcher = $event_dispatcher;
    if ($messenger) {
        @trigger_error('Calling LayoutBuilder::__construct() with the $messenger argument is deprecated in drupal:9.1.0 and will be removed in drupal:10.0.0. See https://www.drupal.org/node/3152690', E_USER_DEPRECATED);
    }
}

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