delivery-8.x-1.x-dev/modules/delivery_update/delivery_update.module

modules/delivery_update/delivery_update.module
<?php

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;

/**
 * Implements hook_entity_base_field_info().
 */
function delivery_update_entity_base_field_info(EntityTypeInterface $entity_type) {
  // Add the 'revision_parent' field.
  if ($entity_type->isRevisionable()) {
    $base_field_definitions = [];
    $base_field_definitions['revision_parent'] = BaseFieldDefinition::create('revision_tree')
      ->setLabel(t('Revision parent'))
      ->setDescription(t('Indicates the parent revision ID.'))
      ->setInternal(TRUE)
      ->setTranslatable(FALSE)
      ->setRevisionable(TRUE);

    if ($entity_type->id() === 'workspace') {
      $base_field_definitions['parent_workspace'] = BaseFieldDefinition::create('entity_reference')
        ->setLabel(t('Parent workspace'))
        ->setDescription(t('The parent workspace of this workspace.'))
        ->setSetting('target_type', 'workspace')
        ->setInternal(TRUE)
        ->setTranslatable(FALSE)
        ->setRevisionable(TRUE)
        ->setDisplayOptions('form', [
          'type' => 'entity_reference_autocomplete',
          'weight' => 5,
        ])
        ->setDisplayConfigurable('form', TRUE);
    }

    return $base_field_definitions;
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc