function EntityField::__construct

Same name in other branches
  1. 8.x-3.x modules/ctools_block/src/Plugin/Block/EntityField.php \Drupal\ctools_block\Plugin\Block\EntityField::__construct()

Constructs a new EntityField.

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.

\Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager: The field type manager.

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

Overrides BlockPluginTrait::__construct

File

modules/ctools_block/src/Plugin/Block/EntityField.php, line 104

Class

EntityField
Provides a block to a field on an entity.

Namespace

Drupal\ctools_block\Plugin\Block

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, FormatterPluginManager $formatter_manager) {
    $this->entityTypeManager = $entity_type_manager;
    $this->entityFieldManager = $entity_field_manager;
    $this->fieldTypeManager = $field_type_manager;
    $this->formatterManager = $formatter_manager;
    // Get the entity type and field name from the plugin id.
    [
        ,
        $entity_type_id,
        $field_name,
    ] = explode(':', $plugin_id);
    $this->entityTypeId = $entity_type_id;
    $this->fieldName = $field_name;
    parent::__construct($configuration, $plugin_id, $plugin_definition);
}