-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPluginClassBase.php
More file actions
93 lines (79 loc) · 2.05 KB
/
PluginClassBase.php
File metadata and controls
93 lines (79 loc) · 2.05 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace DrupalCodeBuilder\Generator;
use MutableTypedData\Definition\PropertyListInterface;
/**
* General class for plugin classes.
*
* Used for:
* - plugin base classes
* - base class for class-based discovery plugins
* - custom plugin class for Yaml-based discovery plugins.
*/
class PluginClassBase extends PHPClassFileWithInjection {
/**
* {@inheritdoc}
*/
protected const CLASS_DI_INTERFACE = '\Drupal\Core\Plugin\ContainerFactoryPluginInterface';
/**
* The plugin type data.
*
* @var array
*/
protected $plugin_type_data;
/**
* The standard fixed create() parameters.
*
* These are the parameters to create() that come after the $container
* parameter.
*
* @var array
*/
const STANDARD_FIXED_PARAMS = [
[
'name' => 'configuration',
'description' => 'A configuration array containing information about the plugin instance.',
'typehint' => 'array',
],
[
'name' => 'plugin_id',
'description' => 'The plugin_id for the plugin instance.',
'typehint' => 'string',
],
[
'name' => 'plugin_definition',
'description' => 'The plugin implementation definition.',
'typehint' => 'mixed',
]
];
/**
* {@inheritdoc}
*/
public static function addToGeneratorDefinition(PropertyListInterface $definition) {
parent::addToGeneratorDefinition($definition);
$definition->getProperty('use_static_factory_method')
->setLiteralDefault(TRUE);
}
/**
* {@inheritdoc}
*/
protected function getConstructBaseParameters() {
return static::STANDARD_FIXED_PARAMS;
}
/**
* {@inheritdoc}
*/
protected function getCreateParameters() {
return static::STANDARD_FIXED_PARAMS;
}
/**
* {@inheritdoc}
*/
public function requiredComponents(): array {
$components = parent::requiredComponents();
// TODO: remove this once tests are updated.
if (isset($components['construct'])) {
$components['construct']['use_primitive_parameter_type_declarations'] = FALSE;
}
return $components;
}
}