This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
SparqlTest.php
73 lines (60 loc) · 1.77 KB
/
SparqlTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types = 1);
namespace Drupal\sparql_test\Entity;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Defines a testing entity.
*
* @ContentEntityType(
* id = "sparql_test",
* label = @Translation("SPARQL test entity"),
* handlers = {
* "storage" = "\Drupal\sparql_entity_storage\SparqlEntityStorage",
* },
* base_table = null,
* fieldable = TRUE,
* translatable = TRUE,
* entity_keys = {
* "id" = "id",
* "bundle" = "type",
* "label" = "title",
* "langcode" = "langcode",
* },
* bundle_entity_type = "sparql_type_test",
* links = {
* "canonical" = "/sparql_test/{sparql_test}",
* "edit-form" = "/sparql_test/{sparql_test}/edit",
* "delete-form" = "/sparql_test/{sparql_test}/delete",
* "collection" = "/sparql_test/list"
* },
* )
*/
class SparqlTest extends ContentEntityBase implements EntityChangedInterface {
use EntityChangedTrait;
/**
* The bundle.
*
* @var string
*/
protected $type;
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id'] = BaseFieldDefinition::create('uri')->setLabel(t('ID'));
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Title'))
->setTranslatable(TRUE)
->setRequired(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Authored on'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'));
return $fields;
}
}