Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / link / tests / modules / link_test_base_field / link_test_base_field.module
diff --git a/web/core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module b/web/core/modules/link/tests/modules/link_test_base_field/link_test_base_field.module
new file mode 100644 (file)
index 0000000..94730fa
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * @file
+ * Contains main module functions.
+ */
+
+use Drupal\Core\Entity\EntityTypeInterface;
+use Drupal\Core\Field\BaseFieldDefinition;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\link\LinkItemInterface;
+
+/**
+ * Implements hook_entity_base_field_info().
+ */
+function link_test_base_field_entity_base_field_info(EntityTypeInterface $entity_type) {
+  $fields = [];
+  if ($entity_type->id() === 'entity_test') {
+    $fields['links'] = BaseFieldDefinition::create('link')
+      ->setLabel(t('Links'))
+      ->setRevisionable(TRUE)
+      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
+      ->setDescription(t('Add links to the entity.'))
+      ->setRequired(FALSE)
+      ->setSettings([
+        'link_type' => LinkItemInterface::LINK_GENERIC,
+        'title' => DRUPAL_REQUIRED,
+      ])
+      ->setDisplayOptions('form', [
+        'type' => 'link_default',
+        'weight' => 49,
+      ]);
+  }
+  return $fields;
+}