Pull merge.
[yaffs-website] / web / core / modules / link / tests / modules / link_test_base_field / link_test_base_field.module
1 <?php
2
3 /**
4  * @file
5  * Contains main module functions.
6  */
7
8 use Drupal\Core\Entity\EntityTypeInterface;
9 use Drupal\Core\Field\BaseFieldDefinition;
10 use Drupal\Core\Field\FieldStorageDefinitionInterface;
11 use Drupal\link\LinkItemInterface;
12
13 /**
14  * Implements hook_entity_base_field_info().
15  */
16 function link_test_base_field_entity_base_field_info(EntityTypeInterface $entity_type) {
17   $fields = [];
18   if ($entity_type->id() === 'entity_test') {
19     $fields['links'] = BaseFieldDefinition::create('link')
20       ->setLabel(t('Links'))
21       ->setRevisionable(TRUE)
22       ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
23       ->setDescription(t('Add links to the entity.'))
24       ->setRequired(FALSE)
25       ->setSettings([
26         'link_type' => LinkItemInterface::LINK_GENERIC,
27         'title' => DRUPAL_REQUIRED,
28       ])
29       ->setDisplayOptions('form', [
30         'type' => 'link_default',
31         'weight' => 49,
32       ]);
33   }
34   return $fields;
35 }