You are here

public static function ProductBundleWidgetBase::isApplicable in Commerce Product Bundle 8

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/ProductBundleWidgetBase.php, line 105

Class

ProductBundleWidgetBase
Provides the base structure for product bundle widgets.

Namespace

Drupal\commerce_product_bundle\Plugin\Field\FieldWidget

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $entity_type = $field_definition
    ->getTargetEntityTypeId();
  $field_name = $field_definition
    ->getName();

  // @todo Check that this field is only a commerce_product_bundle type field.
  return $entity_type == 'commerce_order_item' && $field_name == 'purchased_entity';
}