protected function isPluginCompatible(PluginDescription $plugin, $enabledPlugins, $title, $mode, $script, Map $map)
    {

        // first check for other plugins.
        foreach ($plugin->getParents() as $parentPluginId) {
            if (!isset($enabledPlugins[$parentPluginId])) {
                // A parent plugin is missing. Can't enable plugin.
                return false;
            }
        }

        // Now check for data providers.
        foreach ($plugin->getDataProviders() as $dataProvider) {
            $dataProviders = explode("|", $dataProvider);
            $foundOne = false;

            foreach ($dataProviders as $provider) {
                $providerId = $this->dataProviderManager->getCompatibleProviderId($provider, $title, $mode, $script, $map);
                if (!is_null($providerId) && isset($enabledPlugins[$providerId])) {
                    // Either there are no data providers compatible or the only one compatible
                    $foundOne = true;
                    break;
                }
            }

            if (!$foundOne) {
                return false;
            }
        }

        // If data provider need to check if it was "the chosen one".
        if ($plugin->isIsDataProvider()) {
            $selectedProvider = $this->dataProviderManager->getCompatibleProviderId(
                $plugin->getDataProviderName(),
                $title,
                $mode,
                $script,
                $map
            );

            if ($plugin->getPluginId() != $selectedProvider) {
                // This data provider wasn't the one selected and therefore the plugin isn't compatible.
                return false;
            }
        }

        return true;
    }