You are here

public static function VideoPlayerFormatter::isApplicable in Video 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/VideoPlayerFormatter.php \Drupal\video\Plugin\Field\FieldFormatter\VideoPlayerFormatter::isApplicable()

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 FormatterBase::isApplicable

1 method overrides VideoPlayerFormatter::isApplicable()
VideoPlayerListFormatter::isApplicable in src/Plugin/Field/FieldFormatter/VideoPlayerListFormatter.php
Returns if the formatter can be used for the provided field.

File

src/Plugin/Field/FieldFormatter/VideoPlayerFormatter.php, line 185

Class

VideoPlayerFormatter
Plugin implementation of the 'video_player' formatter.

Namespace

Drupal\video\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  if (empty($field_definition
    ->getTargetBundle())) {
    return TRUE;
  }
  else {
    $entity_form_display = entity_get_form_display($field_definition
      ->getTargetEntityTypeId(), $field_definition
      ->getTargetBundle(), 'default');
    $widget = $entity_form_display
      ->getRenderer($field_definition
      ->getName());
    $widget_id = $widget
      ->getBaseId();
    if ($widget_id == 'video_upload') {
      return TRUE;
    }
  }
  return FALSE;
}