You are here

public static function OptionsShsWidget::isApplicable in Simple hierarchical select 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldWidget/OptionsShsWidget.php \Drupal\shs\Plugin\Field\FieldWidget\OptionsShsWidget::isApplicable()

Returns if the widget can be used for the provided field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition that should be checked.

Return value

bool TRUE if the widget can be used, FALSE otherwise.

Overrides WidgetBase::isApplicable

File

src/Plugin/Field/FieldWidget/OptionsShsWidget.php, line 253

Class

OptionsShsWidget
Plugin implementation of the 'options_shs' widget.

Namespace

Drupal\shs\Plugin\Field\FieldWidget

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {

  // The widget currently only works for taxonomy terms.
  if (strpos($field_definition
    ->getSetting('handler'), 'taxonomy_term') === FALSE) {
    return FALSE;
  }

  // The widget only works with fields having one target bundle as source.
  $handler_settings = $field_definition
    ->getSetting('handler_settings');
  return isset($handler_settings['target_bundles']) && count($handler_settings['target_bundles']) === 1;
}