public function ParagraphsConversionManager::supportsConversion

Checks if the paragraph supports conversion.

Loop over the plugin definitions and in the first supported plugin return TRUE.

Parameters

\Drupal\paragraphs\ParagraphInterface $paragraph: The paragraph.

array $allowed_types: (optional) The parent fields allowed paragraph types.

Return value

bool Whether the current paragraph supports conversion.

File

paragraphs/src/ParagraphsConversionManager.php, line 137

Class

ParagraphsConversionManager
Plugin type manager for paragraphs type conversion plugins.

Namespace

Drupal\paragraphs

Code

public function supportsConversion(ParagraphInterface $paragraph, array $allowed_types = NULL) {
  $definitions = $this
    ->getDefinitions();
  foreach ($definitions as $key => $definition) {

    /** @var \Drupal\paragraphs\ParagraphsConversionInterface $plugin */
    $plugin = $this
      ->createInstance($key);
    if ($plugin && $this
      ->isApplicable($plugin, $paragraph, $allowed_types)) {
      return TRUE;
    }
  }
  return FALSE;
}