class ElementInfo in Express 8
Implements hook_element_info_alter().
Plugin annotation
@BootstrapAlter("element_info");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\bootstrap\Plugin\PluginBase
- class \Drupal\bootstrap\Plugin\Alter\ElementInfo implements AlterInterface
- class \Drupal\bootstrap\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ElementInfo
File
- themes/
contrib/ bootstrap/ src/ Plugin/ Alter/ ElementInfo.php, line 22 - Contains \Drupal\bootstrap\Plugin\Alter\ElementInfo.
Namespace
Drupal\bootstrap\Plugin\AlterView source
class ElementInfo extends PluginBase implements AlterInterface {
/**
* {@inheritdoc}
*/
public function alter(&$types, &$context1 = NULL, &$context2 = NULL) {
// Sort the types for easier debugging.
ksort($types, SORT_NATURAL);
$extra_variables = Bootstrap::extraVariables();
$process_manager = new ProcessManager($this->theme);
$pre_render_manager = new PrerenderManager($this->theme);
foreach (array_keys($types) as $type) {
$element =& $types[$type];
// By default, the "checkboxes" and "radios" element types invoke
// CompositeFormElementTrait::preRenderCompositeFormElement which wraps
// the element in a fieldset and thus ultimately a panel. This isn't
// (usually) the desired effect for these elements, so to avoid rendering
// them as Bootstrap panels, the #bootstrap_panel should be set to FALSE
// by default. This allows those who wish to opt back in to do so.
if ($type === 'checkboxes' || $type === 'radios') {
$element['#bootstrap_panel'] = FALSE;
}
// Core does not actually use the "description_display" property on the
// "details" or "fieldset" element types because the positioning of the
// description is never used in core templates. However, the form builder
// automatically applies the value of "after", thus making it impossible
// to detect a valid value later in the rendering process. It looks better
// for the "details" and "fieldset" element types to display as "before".
// @see \Drupal\Core\Form\FormBuilder::doBuildForm()
if ($type === 'details' || $type === 'fieldset') {
$element['#description_display'] = 'before';
$element['#panel_type'] = 'default';
}
// Add extra variables as defaults to all elements.
foreach ($extra_variables as $key => $value) {
if (!isset($element["#{$key}"])) {
$element["#{$key}"] = $value;
}
}
// Only continue if the type isn't "form" (as it messes up AJAX).
if ($type !== 'form') {
$regex = "/^{$type}/";
// Add necessary #process callbacks.
$element['#process'][] = [
get_class($process_manager),
'process',
];
$definitions = $process_manager
->getDefinitionsLike($regex);
foreach ($definitions as $definition) {
Bootstrap::addCallback($element['#process'], [
$definition['class'],
'process',
], $definition['replace'], $definition['action']);
}
// Add necessary #pre_render callbacks.
$element['#pre_render'][] = [
get_class($pre_render_manager),
'preRender',
];
foreach ($pre_render_manager
->getDefinitionsLike($regex) as $definition) {
Bootstrap::addCallback($element['#pre_render'], [
$definition['class'],
'preRender',
], $definition['replace'], $definition['action']);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
ElementInfo:: |
public | function |
Alters data for a specific hook_TYPE_alter() implementation. Overrides AlterInterface:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
protected | property | The currently set theme object. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
1 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |