function EntityTypeInfo::entityBaseFieldInfo

Implements hook_entity_base_field_info().

Attributes

#[Hook('entity_base_field_info')]

File

core/modules/workspaces/src/Hook/EntityTypeInfo.php, line 110

Class

EntityTypeInfo
Defines a class for reacting to entity type information hooks.

Namespace

Drupal\workspaces\Hook

Code

public function entityBaseFieldInfo(EntityTypeInterface $entity_type) : array {
  if ($this->workspaceInfo
    ->isEntityTypeSupported($entity_type)) {
    $field_name = $entity_type->getRevisionMetadataKey('workspace');
    $fields[$field_name] = BaseFieldDefinition::create('entity_reference')->setLabel(new TranslatableMarkup('Workspace'))
      ->setDescription(new TranslatableMarkup('Indicates the workspace that this revision belongs to.'))
      ->setSetting('target_type', 'workspace')
      ->setInternal(TRUE)
      ->setTranslatable(FALSE)
      ->setRevisionable(TRUE);
    return $fields;
  }
  return [];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.