You are here

protected function FieldBlock::getFieldDefinition in Field as Block 8.2

Gets the field definition.

A FieldBlock works on an entity type across bundles, and thus only has access to field storage definitions. In order to be able to use formatters, we create a generic field definition out of that storage definition.

Parameters

string $field_name: The field name.

Return value

\Drupal\Core\Field\FieldDefinitionInterface The field definition used by this block.

See also

BaseFieldDefinition::createFromFieldStorageDefinition()

\Drupal\views\Plugin\views\field\Field::getFieldDefinition()

1 call to FieldBlock::getFieldDefinition()
FieldBlock::blockForm in src/Plugin/Block/FieldBlock.php

File

src/Plugin/Block/FieldBlock.php, line 184

Class

FieldBlock
Provides a fieldblock.

Namespace

Drupal\fieldblock\Plugin\Block

Code

protected function getFieldDefinition($field_name) {
  $field_storage_config = $this
    ->getFieldStorageDefinition($field_name);
  return BaseFieldDefinition::createFromFieldStorageDefinition($field_storage_config);
}