function FieldBlock::__construct
Same name in other branches
- 8.9.x core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::__construct()
- 10 core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::__construct()
- 11.x 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\BlockCode
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.
[
,
$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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.