function FieldBlock::getApplicablePluginOptions
Same name in other branches
- 8.9.x core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::getApplicablePluginOptions()
- 10 core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::getApplicablePluginOptions()
- 11.x core/modules/layout_builder/src/Plugin/Block/FieldBlock.php \Drupal\layout_builder\Plugin\Block\FieldBlock::getApplicablePluginOptions()
Returns an array of applicable formatter options for a field.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
Return value
array An array of applicable formatter options.
See also
\Drupal\field_ui\Form\EntityDisplayFormBase::getApplicablePluginOptions()
1 call to FieldBlock::getApplicablePluginOptions()
- FieldBlock::blockForm in core/
modules/ layout_builder/ src/ Plugin/ Block/ FieldBlock.php
File
-
core/
modules/ layout_builder/ src/ Plugin/ Block/ FieldBlock.php, line 375
Class
- FieldBlock
- Provides a block that renders a field from an entity.
Namespace
Drupal\layout_builder\Plugin\BlockCode
protected function getApplicablePluginOptions(FieldDefinitionInterface $field_definition) {
$options = $this->formatterManager
->getOptions($field_definition->getType());
$applicable_options = [];
foreach ($options as $option => $label) {
$plugin_class = DefaultFactory::getPluginClass($option, $this->formatterManager
->getDefinition($option));
if ($plugin_class::isApplicable($field_definition)) {
$applicable_options[$option] = $label;
}
}
return $applicable_options;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.