-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathModule7AndLower.php
More file actions
87 lines (73 loc) · 2.75 KB
/
Module7AndLower.php
File metadata and controls
87 lines (73 loc) · 2.75 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
<?php
namespace DrupalCodeBuilder\Generator;
use MutableTypedData\Definition\PropertyListInterface;
use DrupalCodeBuilder\Definition\PropertyDefinition;
use DrupalCodeBuilder\Definition\DeferredGeneratorDefinition;
use DrupalCodeBuilder\Attribute\DrupalCoreVersion;
use DrupalCodeBuilder\Attribute\RelatedBaseClass;
/**
* Module generator for Drupal versions 5, 6, and 7.
*/
#[DrupalCoreVersion(7)]
#[DrupalCoreVersion(6)]
#[DrupalCoreVersion(5)]
#[RelatedBaseClass('Module')]
class Module7AndLower extends Module8 {
/**
* {@inheritdoc}
*/
public static function configurationDefinition(): PropertyDefinition {
return PropertyDefinition::create('complex');
}
/**
* {@inheritdoc}
*/
public static function addToGeneratorDefinition(PropertyListInterface $definition) {
parent::addToGeneratorDefinition($definition);
$definition->removeProperty('plugins');
$definition->removeProperty('plugin_types');
$definition->removeProperty('services');
$definition->removeProperty('event_subscribers');
$definition->removeProperty('service_provider');
$definition->removeProperty('phpunit_tests');
$definition->getProperty('tests')->setDescription('');
$definition->removeProperty('config_entity_types');
$definition->removeProperty('drush_commands');
// TODO: implement these for D7.
$definition->removeProperty('content_entity_types');
$definition->removeProperty('theme_hooks');
$definition->removeProperty('forms');
$definition->addProperties([
'router_items' => DeferredGeneratorDefinition::createFromGeneratorType('RouterItem', 'string')
->setLabel("Menu paths")
->setDescription("Paths for hook_menu(), eg 'path/foo'")
->setMultiple(TRUE),
'settings_form' => DeferredGeneratorDefinition::createFromGeneratorType('AdminSettingsForm', 'boolean')
->setLabel("Admin settings form")
->setDescription("A form for setting the module's general settings. Also produces a permission and a menu item."),
]);
// Make the hook implementation type internal with a default value, as on D7
// and lower hooks can only be procedural.
$definition->getProperty('hook_implementation_type')
->setInternal(TRUE)
->setLiteralDefault('procedural');
}
/**
* {@inheritdoc}
*/
public static function rootComponentPropertyDefinitionAlter(PropertyDefinition $definition): void {
// Do nothing.
}
/**
* {@inheritdoc}
*/
public function requiredComponents(): array {
$components = parent::requiredComponents();
// On D7 and lower, modules need a .module file, even if empty.
$components['%module.module'] = [
'component_type' => 'ExtensionCodeFile',
'filename' => '%module.module',
];
return $components;
}
}