You are here

public function ExtraFieldBlock::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 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.
  list(, , , $field_name) = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 4);
  assert(!empty($field_name));
  $this->fieldName = $field_name;
  parent::__construct($configuration, $plugin_id, $plugin_definition);
}