protected function YamlFormUiElementTypeFormBase::getDefinitions in YAML Form 8
Gets the sorted definition of all YamlFormElement plugins.
Return value
array An array of YamlFormElement plugin definitions. Keys are element types.
2 calls to YamlFormUiElementTypeFormBase::getDefinitions()
- YamlFormUiElementTypeChangeForm::buildForm in modules/
yamlform_ui/ src/ Form/ YamlFormUiElementTypeChangeForm.php - Form constructor.
- YamlFormUiElementTypeSelectForm::buildForm in modules/
yamlform_ui/ src/ Form/ YamlFormUiElementTypeSelectForm.php - Form constructor.
File
- modules/
yamlform_ui/ src/ Form/ YamlFormUiElementTypeFormBase.php, line 54
Class
- YamlFormUiElementTypeFormBase
- Provides a abstract element type form for a form element.
Namespace
Drupal\yamlform_ui\FormCode
protected function getDefinitions() {
$definitions = $this->elementManager
->getDefinitions();
$definitions = $this->elementManager
->getSortedDefinitions($definitions, 'category');
$grouped_definitions = $this->elementManager
->getGroupedDefinitions($definitions);
// Get definitions with basic and advanced first and uncategorized elements
// last.
$no_category = '';
$basic_category = (string) $this
->t('Basic elements');
$advanced_category = (string) $this
->t('Advanced elements');
$uncategorized = $grouped_definitions[$no_category];
$sorted_definitions = [];
$sorted_definitions += $grouped_definitions[$basic_category];
$sorted_definitions += $grouped_definitions[$advanced_category];
unset($grouped_definitions[$basic_category], $grouped_definitions[$advanced_category], $grouped_definitions[$no_category]);
foreach ($grouped_definitions as $grouped_definition) {
$sorted_definitions += $grouped_definition;
}
$sorted_definitions += $uncategorized;
foreach ($sorted_definitions as &$plugin_definition) {
if (!isset($plugin_definition['category'])) {
$plugin_definition['category'] = $this
->t('Other elements');
}
}
return $sorted_definitions;
}