public static function UsageLimitWidget::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/
promotion/ src/ Plugin/ Field/ FieldWidget/ UsageLimitWidget.php, line 151
Class
- UsageLimitWidget
- Plugin implementation of 'commerce_usage_limit'.
Namespace
Drupal\commerce_promotion\Plugin\Field\FieldWidgetCode
public static function isApplicable(FieldDefinitionInterface $field_definition) {
$entity_type = $field_definition
->getTargetEntityTypeId();
$field_name = $field_definition
->getName();
$applicable_entity_type = in_array($entity_type, [
'commerce_promotion',
'commerce_promotion_coupon',
]);
$applicable_field_name = in_array($field_name, [
'usage_limit',
'usage_limit_customer',
]);
return $applicable_entity_type && $applicable_field_name;
}