protected function WebformElementManager::alterDefinitions in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElementManager.php \Drupal\webform\Plugin\WebformElementManager::alterDefinitions()
Invokes the hook to alter the definitions if the alter hook is set.
Parameters
$definitions: The discovered plugin definitions.
Overrides DefaultPluginManager::alterDefinitions
File
- src/
Plugin/ WebformElementManager.php, line 89
Class
- WebformElementManager
- Provides a plugin manager for webform element plugins.
Namespace
Drupal\webform\PluginCode
protected function alterDefinitions(&$definitions) {
// Prevents Fatal error: Class 'Drupal\bootstrap\Bootstrap' during install
// w/ Bootstrap theme and webform.
$this->themeHandler
->reset();
// Unset elements that are missing target element or dependencies.
foreach ($definitions as $element_key => $element_definition) {
// Check that the webform element's target element info exists.
if (!$this->elementInfo
->getInfo($element_key)) {
unset($definitions[$element_key]);
continue;
}
// Check element's (module) dependencies exist.
foreach ($element_definition['dependencies'] as $dependency) {
if (!$this->moduleHandler
->moduleExists($dependency)) {
unset($definitions[$element_key]);
continue;
}
}
}
parent::alterDefinitions($definitions);
}