public function ParagraphsConversionManager::getApplicableDefinitions

Gets the applicable conversion plugins.

Loop over the plugin definitions, check the applicability of each one of them and return the array of the applicable plugins.

Parameters

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

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

Return value

array The applicable conversion plugins.

File

paragraphs/src/ParagraphsConversionManager.php, line 68

Class

ParagraphsConversionManager
Plugin type manager for paragraphs type conversion plugins.

Namespace

Drupal\paragraphs

Code

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

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