You are here

public static function ParagraphsWidget::isApplicable in Paragraphs 8

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

src/Plugin/Field/FieldWidget/ParagraphsWidget.php, line 2501

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

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;
}