FieldAPIHandlerTrait::getFieldDefinition

protected FieldAPIHandlerTrait::getFieldDefinition()

Gets the field definition.

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

Return value

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

See also

BaseFieldDefinition::createFromFieldStorageDefinition()

File

core/modules/views/src/FieldAPIHandlerTrait.php, line 39

Class

FieldAPIHandlerTrait
A trait containing helper methods for field definitions.

Namespace

Drupal\views

Code

protected function getFieldDefinition() {
  if (!$this->fieldDefinition) {
    $field_storage_config = $this->getFieldStorageDefinition();
    $this->fieldDefinition = BaseFieldDefinition::createFromFieldStorageDefinition($field_storage_config);
  }
  return $this->fieldDefinition;
}
doc_Drupal
2016-10-29 09:10:33
Comments
Leave a Comment

Please login to continue.