/**
  * Returns an array of applicable widget or formatter options for a field.
  *
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The field definition.
  *
  * @return array
  *   An array of applicable widget or formatter options.
  */
 protected function getApplicablePluginOptions(FieldDefinitionInterface $field_definition)
 {
     $options = $this->pluginManager->getOptions($field_definition->getType());
     $applicable_options = array();
     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;
 }
예제 #2
0
 /**
  * Returns an array of widget or formatter options for a field type.
  *
  * @param string $field_type
  *   The name of the field type.
  *
  * @return array
  *   An array of widget or formatter options.
  */
 protected function getPluginOptions($field_type)
 {
     return $this->pluginManager->getOptions($field_type);
 }