You are here

public function EntityTypeInfo::entityBaseFieldInfo in Workspace 8

Adds base field info to an entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: Entity type for adding base fields to.

Return value

\Drupal\Core\Field\BaseFieldDefinition[] New fields added Workspace.

File

src/EntityTypeInfo.php, line 157

Class

EntityTypeInfo
Service class for manipulating entity type information.

Namespace

Drupal\workspace

Code

public function entityBaseFieldInfo(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->id() != 'workspace') {
    return [];
  }
  $fields['upstream'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Assign default target workspace'))
    ->setDescription(t('The workspace to push to and pull from.'))
    ->setRevisionable(TRUE)
    ->setRequired(TRUE)
    ->setSetting('target_type', 'workspace_pointer')
    ->setDefaultValueCallback('workspace_active_id')
    ->setDisplayOptions('form', [
    'type' => 'options_target_workspace_select',
    'weight' => 5,
  ]);
  $fields['pull_replication_settings'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Replication settings on update'))
    ->setDescription(t('The settings to use when content is pulled from upstream.'))
    ->setRevisionable(TRUE)
    ->setSetting('target_type', 'replication_settings')
    ->setDisplayOptions('form', [
    'type' => 'options_filters_select',
    'weight' => 6,
  ]);
  $fields['push_replication_settings'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Replication settings on deploy'))
    ->setDescription(t('The settings to use when content is pushed to upstream.'))
    ->setRevisionable(TRUE)
    ->setSetting('target_type', 'replication_settings')
    ->setDisplayOptions('form', [
    'type' => 'options_filters_select',
    'weight' => 7,
  ]);
  return $fields;
}