You are here

public static function PriceDifferenceFormatter::isApplicable in Price Difference Formatter 8

Returns if the formatter 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 formatter can be used, FALSE otherwise.

Overrides PriceCalculatedFormatter::isApplicable

File

src/Plugin/Field/FieldFormatter/PriceDifferenceFormatter.php, line 150

Class

PriceDifferenceFormatter
Plugin implementation of the 'price_difference_formatter' formatter.

Namespace

Drupal\price_difference_formatter\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($field_definition
    ->getTargetEntityTypeId());
  return $entity_type
    ->entityClassImplements(PurchasableEntityInterface::class) || $entity_type
    ->entityClassImplements(OrderItemInterface::class);
}