You are here

public static function ReferenceWidget::isApplicable in Select (or other) 8.3

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

1 call to ReferenceWidget::isApplicable()
ReferenceWidgetTest::testIsApplicable in Tests/src/Unit/ReferenceWidgetTest.php
Tests if the widget correctly determines if it is applicable.

File

src/Plugin/Field/FieldWidget/EntityReference/ReferenceWidget.php, line 215
Contains \Drupal\select_or_other\Plugin\Field\FieldWidget\EntityReference\ReferenceWidget.

Class

ReferenceWidget
Plugin implementation of the 'select_or_other_reference' widget.

Namespace

Drupal\select_or_other\Plugin\Field\FieldWidget\EntityReference

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $options = $field_definition
    ->getSettings();
  $handler = \Drupal::service('plugin.manager.entity_reference_selection')
    ->getInstance($options);
  return $handler instanceof SelectionWithAutocreateInterface && $options['handler_settings']['auto_create'];
}