You are here

public function FieldBlock::__construct in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::__construct()

Constructs a new FieldBlock.

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\EntityFieldManagerInterface $entity_field_manager: The entity field manager.

\Drupal\Core\Field\FormatterPluginManager $formatter_manager: The formatter manager.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler.

\Psr\Log\LoggerInterface $logger: The logger.

Overrides BlockPluginTrait::__construct

File

core/modules/layout_builder/src/Plugin/Block/FieldBlock.php, line 114

Class

FieldBlock
Provides a block that renders a field from an entity.

Namespace

Drupal\layout_builder\Plugin\Block

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityFieldManagerInterface $entity_field_manager, FormatterPluginManager $formatter_manager, ModuleHandlerInterface $module_handler, LoggerInterface $logger) {
  $this->entityFieldManager = $entity_field_manager;
  $this->formatterManager = $formatter_manager;
  $this->moduleHandler = $module_handler;
  $this->logger = $logger;

  // Get the entity type and field name from the plugin ID.
  list(, $entity_type_id, $bundle, $field_name) = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 4);
  $this->entityTypeId = $entity_type_id;
  $this->bundle = $bundle;
  $this->fieldName = $field_name;
  parent::__construct($configuration, $plugin_id, $plugin_definition);
}