-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathEntityHandler.php
More file actions
39 lines (31 loc) · 1.28 KB
/
EntityHandler.php
File metadata and controls
39 lines (31 loc) · 1.28 KB
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
<?php
namespace DrupalCodeBuilder\Generator;
use MutableTypedData\Definition\PropertyListInterface;
use DrupalCodeBuilder\Definition\PropertyDefinition;
use MutableTypedData\Definition\DefaultDefinition;
/**
* Generator for entity handler classes.
*/
class EntityHandler extends PHPClassFile {
/**
* {@inheritdoc}
*/
public static function addToGeneratorDefinition(PropertyListInterface $definition) {
parent::addToGeneratorDefinition($definition);
$definition->addProperties([
'entity_type_id' => PropertyDefinition::create('string')
->setAutoAcquiredFromRequester(),
'plain_class_name' => PropertyDefinition::create('string')
->setInternal(TRUE),
'entity_type_label' => PropertyDefinition::create('string')
->setAutoAcquiredFromRequester(),
'handler_type' => PropertyDefinition::create('string')
->setInternal(TRUE),
'handler_label' => PropertyDefinition::create('string')
->setInternal(TRUE),
]);
// Note that relative_class_name is given by the entity type component.
$definition->getProperty('class_docblock_lines')->setDefault(DefaultDefinition::create()
->setExpression("['Provides the ' ~ get('..:handler_label') ~ ' handler for the ' ~ get('..:entity_type_label') ~ ' entity.']"));
}
}