You are here

public static function InlineParagraphsWidget::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/InlineParagraphsWidget.php, line 1503

Class

InlineParagraphsWidget
Plugin implementation of the 'entity_reference 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;
}