Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Entity / EntityTestFieldOverride.php
1 <?php
2
3 namespace Drupal\entity_test\Entity;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6
7 /**
8  * Defines a test entity class for testing default values.
9  *
10  * @ContentEntityType(
11  *   id = "entity_test_field_override",
12  *   label = @Translation("Test entity field overrides"),
13  *   base_table = "entity_test_field_override",
14  *   entity_keys = {
15  *     "id" = "id",
16  *     "uuid" = "uuid",
17  *     "bundle" = "type"
18  *   }
19  * )
20  */
21 class EntityTestFieldOverride extends EntityTest {
22
23   /**
24    * {@inheritdoc}
25    */
26   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
27     $fields = parent::baseFieldDefinitions($entity_type);
28     $fields['name']->setDescription('The default description.');
29     return $fields;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
36     $fields = parent::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions);
37
38     if ($bundle == 'some_test_bundle') {
39       $fields['name'] = clone $base_field_definitions['name'];
40       $fields['name']->setDescription('Custom description.');
41     }
42     return $fields;
43   }
44
45 }