You are here

public static function ProductVariationWidgetBase::isApplicable in Commerce Core 8.2

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

modules/product/src/Plugin/Field/FieldWidget/ProductVariationWidgetBase.php, line 84

Class

ProductVariationWidgetBase
Provides the base structure for product variation widgets.

Namespace

Drupal\commerce_product\Plugin\Field\FieldWidget

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $entity_type = $field_definition
    ->getTargetEntityTypeId();
  $field_name = $field_definition
    ->getName();
  return $entity_type == 'commerce_order_item' && $field_name == 'purchased_entity';
}