Version 1
[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   public $group = 'default';
38
39   /**
40    * The group label.
41    *
42    * @var \Drupal\Core\Annotation\Translation
43    *
44    * @ingroup plugin_translatable
45    */
46   public $group_label = '';
47
48   /**
49    * {@inheritdoc}
50    */
51   public function get() {
52     $values = $this->definition;
53
54     // Use the specified entity type class, and remove it before instantiating.
55     $class = $values['entity_type_class'];
56     unset($values['entity_type_class']);
57
58     return new $class($values);
59   }
60
61 }