You are here

protected function ExtensionManager::createObjectRequirement in Markdown 8.2

Overrides InstallablePluginManager::createObjectRequirement

File

src/PluginManager/ExtensionManager.php, line 112

Class

ExtensionManager
Markdown Extension Plugin Manager.

Namespace

Drupal\markdown\PluginManager

Code

protected function createObjectRequirement(InstallablePlugin $definition, InstallableLibrary $library) {
  $objectRequirement = parent::createObjectRequirement($definition, $library);
  $id = $objectRequirement->constraints['Installed']['name'];

  /* @var \Drupal\markdown\PluginManager\ParserManagerInterface $parserManager */
  $parserManager = \Drupal::service('plugin.manager.markdown.parser');
  $parser = $parserManager
    ->getDefinitionByLibraryId($id);
  foreach ($library->requirements as $requirement) {
    if ($requirement
      ->getId() === $id || $parser && $requirement
      ->getType() === 'parser' && $requirement
      ->getTypeId() === $parser
      ->getId()) {
      return NULL;
    }
  }
  return $objectRequirement;
}