Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Entity / EntityTestMulChanged.php
1 <?php
2
3 namespace Drupal\entity_test\Entity;
4
5 use Drupal\Core\Entity\EntityChangedInterface;
6 use Drupal\Core\Entity\EntityChangedTrait;
7 use Drupal\Core\Entity\EntityTypeInterface;
8 use Drupal\Core\Field\BaseFieldDefinition;
9
10 /**
11  * Defines the test entity class.
12  *
13  * @ContentEntityType(
14  *   id = "entity_test_mul_changed",
15  *   label = @Translation("Test entity - data table"),
16  *   handlers = {
17  *     "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
18  *     "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
19  *     "form" = {
20  *       "default" = "Drupal\entity_test\EntityTestForm",
21  *       "delete" = "Drupal\entity_test\EntityTestDeleteForm"
22  *     },
23  *     "route_provider" = {
24  *       "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
25  *     },
26  *     "translation" = "Drupal\content_translation\ContentTranslationHandler",
27  *     "views_data" = "Drupal\views\EntityViewsData"
28  *   },
29  *   base_table = "entity_test_mul_changed",
30  *   data_table = "entity_test_mul_changed_property",
31  *   translatable = TRUE,
32  *   entity_keys = {
33  *     "id" = "id",
34  *     "uuid" = "uuid",
35  *     "bundle" = "type",
36  *     "label" = "name",
37  *     "langcode" = "langcode"
38  *   },
39  *   links = {
40  *     "add-form" = "/entity_test_mul_changed/add",
41  *     "canonical" = "/entity_test_mul_changed/manage/{entity_test_mul_changed}",
42  *     "edit-form" = "/entity_test_mul_changed/manage/{entity_test_mul_changed}/edit",
43  *     "delete-form" = "/entity_test/delete/entity_test_mul_changed/{entity_test_mul_changed}",
44  *   },
45  *   field_ui_base_route = "entity.entity_test_mul_changed.admin_form",
46  * )
47  */
48 class EntityTestMulChanged extends EntityTestMul implements EntityChangedInterface {
49
50   use EntityChangedTrait;
51
52   /**
53    * {@inheritdoc}
54    */
55   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
56     $fields = parent::baseFieldDefinitions($entity_type);
57
58     $fields['changed'] = BaseFieldDefinition::create('changed_test')
59       ->setLabel(t('Changed'))
60       ->setDescription(t('The time that the entity was last edited.'))
61       ->setTranslatable(TRUE);
62
63     $fields['not_translatable'] = BaseFieldDefinition::create('string')
64       ->setLabel(t('Non translatable'))
65       ->setDescription(t('A non-translatable string field'));
66
67     return $fields;
68   }
69
70   /**
71    * {@inheritdoc}
72    */
73   public function save() {
74     // Ensure a new timestamp.
75     sleep(1);
76     parent::save();
77   }
78
79 }