-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathConfiguration.php
More file actions
51 lines (42 loc) · 1.41 KB
/
Configuration.php
File metadata and controls
51 lines (42 loc) · 1.41 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
<?php
namespace DrupalCodeBuilder\Task;
use DrupalCodeBuilder\Environment\EnvironmentInterface;
use DrupalCodeBuilder\Task\Generate\ComponentClassHandler;
use DrupalCodeBuilder\MutableTypedData\DrupalCodeBuilderDataItemFactory;
use MutableTypedData\Data\DataItem;
/**
* Task handler for working with configuration.
*
* Configuration consists of options for code generation that users will
* typically want to apply to all code generation on a project. UIs should allow
* for a way to store these persistently and pass them to
* Generate::generateComponent() each time.
*/
class Configuration extends Base {
protected $sanity_level = 'none';
/**
* Constructor.
*
* @param $environment
* The current environment handler.
*/
function __construct(
EnvironmentInterface $environment,
protected ComponentClassHandler $componentClassHandler
) {
$this->environment = $environment;
}
/**
* Returns the data object for the component type's configuration.
*
* UIs should use this to present the options to the user.
*
* @param string $component_type
* The component type, e.g. 'module'.
*/
public function getConfigurationData(string $component_type): DataItem {
$class = $this->componentClassHandler->getGeneratorClass($component_type);
$data = DrupalCodeBuilderDataItemFactory::createFromCallback("{$class}::configurationDefinition");
return $data;
}
}