public static function VideoPlayerFormatter::isApplicable in Video 8.2
Same name and namespace in other branches
- 8 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 183
Class
- VideoPlayerFormatter
- Plugin implementation of the 'video_player' formatter.
Namespace
Drupal\video\Plugin\Field\FieldFormatterCode
public static function isApplicable(FieldDefinitionInterface $field_definition) {
if (empty($field_definition
->getTargetBundle())) {
return TRUE;
}
else {
$form_mode = 'default';
$entity_form_display = \Drupal::entityTypeManager()
->getStorage('entity_form_display')
->load($field_definition
->getTargetEntityTypeId() . '.' . $field_definition
->getTargetBundle() . '.' . $form_mode);
if (!$entity_form_display) {
$entity_form_display = \Drupal::entityTypeManager()
->getStorage('entity_form_display')
->create([
'targetEntityType' => $field_definition
->getTargetEntityTypeId(),
'bundle' => $field_definition
->getTargetBundle(),
'mode' => $form_mode,
'status' => TRUE,
]);
}
$widget = $entity_form_display
->getRenderer($field_definition
->getName());
$widget_id = $widget
->getBaseId();
if ($widget_id == 'video_upload') {
return TRUE;
}
}
return FALSE;
}