You are here

entity_hierarchy_test_base_field.module in Entity Reference Hierarchy 8.2

Contains main module functions.

File

tests/modules/entity_hierarchy_test_base_field/entity_hierarchy_test_base_field.module
View source
<?php

/**
 * @file
 * Contains main module functions.
 */
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;

/**
 * Implements hook_entity_base_field_info().
 */
function entity_hierarchy_test_base_field_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->id() === 'entity_test') {
    return [
      'parents' => BaseFieldDefinition::create('entity_reference_hierarchy')
        ->setCardinality(1)
        ->setSetting('target_type', 'entity_test')
        ->setLabel('Parents'),
    ];
  }
  return [];
}