function ExtraFieldBlock::__construct

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

Constructs a new ExtraFieldBlock.

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.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

\Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager: The entity field manager.

Overrides BlockPluginTrait::__construct

File

core/modules/layout_builder/src/Plugin/Block/ExtraFieldBlock.php, line 71

Class

ExtraFieldBlock
Provides a block that renders an extra field from an entity.

Namespace

Drupal\layout_builder\Plugin\Block

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager) {
    $this->entityTypeManager = $entity_type_manager;
    $this->entityFieldManager = $entity_field_manager;
    // Get field name from the plugin ID.
    [
        ,
        ,
        ,
        $field_name,
    ] = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 4);
    assert(!empty($field_name));
    $this->fieldName = $field_name;
    parent::__construct($configuration, $plugin_id, $plugin_definition);
}

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