40ef788cb998e28454397e287b313e80ff761405
[yaffs-website] / web / modules / contrib / entity / tests / modules / entity_module_test / src / Entity / EnhancedEntity.php
1 <?php
2
3 namespace Drupal\entity_module_test\Entity;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Field\BaseFieldDefinition;
7 use Drupal\entity\Revision\RevisionableContentEntityBase;
8
9 /**
10  * Provides a test entity which uses all the capabilities of entity module.
11  *
12  * @ContentEntityType(
13  *   id = "entity_test_enhanced",
14  *   label = @Translation("Entity test with enhancements"),
15  *   handlers = {
16  *     "storage" = "\Drupal\Core\Entity\Sql\SqlContentEntityStorage",
17  *     "access" = "\Drupal\entity\EntityAccessControlHandler",
18  *     "permission_provider" = "\Drupal\entity\EntityPermissionProvider",
19  *     "form" = {
20  *       "add" = "\Drupal\entity\Form\RevisionableContentEntityForm",
21  *       "edit" = "\Drupal\entity\Form\RevisionableContentEntityForm",
22  *       "delete" = "\Drupal\Core\Entity\EntityDeleteForm",
23  *     },
24  *     "route_provider" = {
25  *       "html" = "\Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
26  *       "revision" = "\Drupal\entity\Routing\RevisionRouteProvider",
27  *       "delete-multiple" = "\Drupal\entity\Routing\DeleteMultipleRouteProvider",
28  *     },
29  *     "list_builder" = "\Drupal\Core\Entity\EntityListBuilder",
30  *   },
31  *   base_table = "entity_test_enhanced",
32  *   data_table = "entity_test_enhanced_field_data",
33  *   revision_table = "entity_test_enhanced_revision",
34  *   revision_data_table = "entity_test_enhanced_field_revision",
35  *   translatable = TRUE,
36  *   revisionable = TRUE,
37  *   admin_permission = "administer entity_test_enhanced",
38  *   permission_granularity = "bundle",
39  *   entity_keys = {
40  *     "id" = "id",
41  *     "bundle" = "type",
42  *     "revision" = "vid",
43  *     "langcode" = "langcode",
44  *   },
45  *   links = {
46  *     "add-page" = "/entity_test_enhanced/add",
47  *     "add-form" = "/entity_test_enhanced/add/{type}",
48  *     "edit-form" = "/entity_test_enhanced/{entity_test_enhanced}/edit",
49  *     "canonical" = "/entity_test_enhanced/{entity_test_enhanced}",
50  *     "collection" = "/entity_test_enhanced",
51  *     "delete-multiple-form" = "/entity_test_enhanced/delete",
52  *     "revision" = "/entity_test_enhanced/{entity_test_enhanced}/revisions/{entity_test_enhanced_revision}/view",
53  *     "revision-revert-form" = "/entity_test_enhanced/{entity_test_enhanced}/revisions/{entity_test_enhanced_revision}/revert",
54  *     "version-history" = "/entity_test_enhanced/{entity_test_enhanced}/revisions",
55  *   },
56  *   bundle_entity_type = "entity_test_enhanced_bundle",
57  * )
58  */
59 class EnhancedEntity extends RevisionableContentEntityBase {
60
61   /**
62    * {@inheritdoc}
63    */
64   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
65     $fields = parent::baseFieldDefinitions($entity_type);
66
67     $fields['name'] = BaseFieldDefinition::create('string')
68       ->setLabel('Name')
69       ->setRevisionable(TRUE)
70       ->setDisplayOptions('view', [
71         'label' => 'hidden',
72         'type' => 'string',
73         'weight' => -5,
74       ]);
75
76     return $fields;
77   }
78
79 }