function EntityDisplayFormBase::getApplicablePluginOptions

Same name in other branches
  1. 9 core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::getApplicablePluginOptions()
  2. 10 core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::getApplicablePluginOptions()
  3. 11.x core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::getApplicablePluginOptions()

Returns an array of applicable widget or formatter options for a field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.

Return value

array An array of applicable widget or formatter options.

1 call to EntityDisplayFormBase::getApplicablePluginOptions()
EntityDisplayFormBase::buildFieldRow in core/modules/field_ui/src/Form/EntityDisplayFormBase.php
Builds the table row structure for a single field.

File

core/modules/field_ui/src/Form/EntityDisplayFormBase.php, line 796

Class

EntityDisplayFormBase
Base class for EntityDisplay edit forms.

Namespace

Drupal\field_ui\Form

Code

protected function getApplicablePluginOptions(FieldDefinitionInterface $field_definition) {
    $options = $this->pluginManager
        ->getOptions($field_definition->getType());
    $applicable_options = [];
    foreach ($options as $option => $label) {
        $plugin_class = DefaultFactory::getPluginClass($option, $this->pluginManager
            ->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.