Checks if the paragraph supports conversion.
Loop over the plugin definitions and in the first supported plugin return TRUE.
\Drupal\paragraphs\ParagraphInterface $paragraph: The paragraph.
array $allowed_types: (optional) The parent fields allowed paragraph types.
bool Whether the current paragraph supports conversion.
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;
}