Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FieldBlock.php

function 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 369

Class

FieldBlock
Provides a block that renders a field from an entity.

Namespace

Drupal\layout_builder\Plugin\Block

Code

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;
}
RSS feed
Powered by Drupal