You are here

public static function ParagraphsSummaryFormatter::isApplicable in Paragraphs 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 FormatterBase::isApplicable

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

File

src/Plugin/Field/FieldFormatter/ParagraphsSummaryFormatter.php, line 62

Class

ParagraphsSummaryFormatter
Plugin implementation of the 'paragraph_summary' formatter.

Namespace

Drupal\paragraphs\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $target_type = $field_definition
    ->getSetting('target_type');
  $paragraph_type = \Drupal::entityTypeManager()
    ->getDefinition($target_type);
  if ($paragraph_type) {
    return $paragraph_type
      ->entityClassImplements(ParagraphInterface::class);
  }
  return FALSE;
}