public static function PhotosImageMediaFieldFormatter::isApplicable in Album Photos 8.5
Same name and namespace in other branches
- 6.0.x src/Plugin/Field/FieldFormatter/PhotosImageMediaFieldFormatter.php \Drupal\photos\Plugin\Field\FieldFormatter\PhotosImageMediaFieldFormatter::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 MediaThumbnailFormatter::isApplicable
File
- src/
Plugin/ Field/ FieldFormatter/ PhotosImageMediaFieldFormatter.php, line 88
Class
- PhotosImageMediaFieldFormatter
- Plugin implementation of the 'media_thumbnail' formatter.
Namespace
Drupal\photos\Plugin\Field\FieldFormatterCode
public static function isApplicable(FieldDefinitionInterface $field_definition) {
// This formatter is only available for entity types that reference
// media items from the photos_image entity type.
$entityType = $field_definition
->getTargetEntityTypeId();
$targetType = $field_definition
->getFieldStorageDefinition()
->getSetting('target_type');
return $entityType == 'photos_image' && $targetType == 'media';
}