protected function FieldBlock::getApplicablePluginOptions in Drupal 9
Same name and namespace in other branches
- 8 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 366
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;
}