public function ComponentSectionFormHandler::__construct in Module Builder 8.3
Constructs a new ComponentSectionFormHandler object.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.
File
- src/
EntityHandler/ ComponentSectionFormHandler.php, line 56
Class
- ComponentSectionFormHandler
- Provides definitions of form sections, paths, titles, and properties used.
Namespace
Drupal\module_builder\EntityHandlerCode
public function __construct(EntityTypeInterface $entity_type) {
$code_builder_annotation = $entity_type
->get('code_builder');
$form_properties = $code_builder_annotation['section_forms'];
if (!isset($form_properties['name'])) {
throw new \Exception("Entity type {$entity_type_id} defines the code_builder annotation, but doesn't have a name form set.");
}
// The 'misc' and 'generate' forms always gets added: the 'misc' shows all
// properties not set to another section..
$form_properties['misc'] = [
"title" => "Edit %label miscellaneous components",
"op_title" => "Edit miscellaneous components",
"tab_title" => "Misc",
// Empty array is needed here for getUsedComponentProperties() to use.
"properties" => [],
];
$form_properties['generate'] = [
"title" => "Generate code for %label",
"op_title" => "Generate code",
"tab_title" => "Generate code",
// Empty array is needed here for getUsedComponentProperties() to use.
"properties" => [],
];
$this->formSectionData = $form_properties;
// The 'name' form gets special treatment.
// TODO: currently hardcoded in the class.
// TODO: rename this class to a more generic name.
//$entity_type->setFormClass('name', \Drupal\module_builder\Form\ModuleNameForm::class);
unset($form_properties['name']);
$this->formSectionDataDynamic = $form_properties;
}