9d14bed06d1475385ac7cba0b32405c8501ad2b0
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Annotation / EntityType.php
1 <?php
2
3 namespace Drupal\Core\Entity\Annotation;
4
5 use Drupal\Component\Annotation\Plugin;
6 use Drupal\Core\StringTranslation\StringTranslationTrait;
7
8 /**
9  * Defines an Entity type annotation object.
10  *
11  * Entity type plugins use an object-based annotation method, rather than an
12  * array-type annotation method (as commonly used on other annotation types).
13  * The annotation properties of entity types are found on
14  * \Drupal\Core\Entity\EntityType and are accessed using get/set methods defined
15  * in \Drupal\Core\Entity\EntityTypeInterface.
16  *
17  * @ingroup entity_api
18  *
19  * @Annotation
20  */
21 class EntityType extends Plugin {
22
23   use StringTranslationTrait;
24
25   /**
26    * The class used to represent the entity type.
27    *
28    * It must implement \Drupal\Core\Entity\EntityTypeInterface.
29    *
30    * @var string
31    */
32   public $entity_type_class = 'Drupal\Core\Entity\EntityType';
33
34   /**
35    * The group machine name.
36    *
37    * @var string
38    */
39   public $group = 'default';
40
41   /**
42    * The group label.
43    *
44    * @var \Drupal\Core\Annotation\Translation
45    *
46    * @ingroup plugin_translatable
47    */
48   public $group_label = '';
49
50   /**
51    * {@inheritdoc}
52    */
53   public function get() {
54     $values = $this->definition;
55
56     // Use the specified entity type class, and remove it before instantiating.
57     $class = $values['entity_type_class'];
58     unset($values['entity_type_class']);
59
60     return new $class($values);
61   }
62
63 }