Enable a certain plugin.

@param PluginDescription $plugin
@param $title
@param $mode
@param $script
@param Map $map

@return mixed

@throws \eXpansion\Framework\Core\Exceptions\DataProvider\UncompatibleException
967684
protected function enablePlugin(PluginDescription $plugin, $title, $mode, $script, Map $map)
    {
        $notify = false;
        $plugin->setIsEnabled(true);
        $pluginService = $this->container->get($plugin->getPluginId());

        if (!isset($this->enabledPlugins[$plugin->getPluginId()])) {
            $notify = true;
        }

        foreach ($plugin->getDataProviders() as $provider) {
            $dataProviders = explode("|", $provider);
            foreach ($dataProviders as $dataProvider) {
                $this->dataProviderManager->registerPlugin($dataProvider, $plugin->getPluginId(), $title, $mode, $script, $map);
            }
        }

        $this->enabledPlugins[$plugin->getPluginId()] = $plugin;

        return $notify ? $pluginService : null;
    }
699393
public void enable() throws IOException {
        if (!disableFile.exists()) {
            LOGGER.log(Level.FINEST, "Plugin {0} has been already enabled. Skipping the enable() operation", getShortName());
            return;
        }
        if(!disableFile.delete())
            throw new IOException("Failed to delete "+disableFile);
    }
895353
public function isEnabled($type, $plugin = null)
	{
		$result = $this->byType($type, $plugin);

		return (!empty($result));
	}
271654
public function htmlModal($identifier, $title="", $content="", $buttonCaptions=array()) {
		return $this->addHtmlComponent(new HtmlModal($identifier, $title, $content, $buttonCaptions));
	}
926190
public function disableAction(Plugin $plugin)
    {
        $this->pluginManager->disable($plugin);

        return new JsonResponse(
            $this->pluginManager->getPluginsData()
        );
    }
599964
public static function selectOne($field, $title, $value = '')
    {
        return self::select($field, $title, (string)$value);
    }
809079
public function activatePlugin($pluginName)
    {
        $plugins = $this->pluginList->getActivatedPlugins();
        if (in_array($pluginName, $plugins)) {
            // plugin is already activated
            return;
        }

        if (!$this->isPluginInFilesystem($pluginName)) {
            throw new \Exception("Plugin '$pluginName' cannot be found in the filesystem in plugins/ directory.");
        }
        $this->deactivateThemeIfTheme($pluginName);

        // Load plugin
        $plugin = $this->loadPlugin($pluginName);
        if ($plugin === null) {
            throw new \Exception("The plugin '$pluginName' was found in the filesystem, but could not be loaded.'");
        }
        $this->installPluginIfNecessary($plugin);
        $plugin->activate();

        EventDispatcher::getInstance()->postPendingEventsTo($plugin);

        $this->pluginsToLoad[] = $pluginName;

        $this->updatePluginsConfig($this->pluginsToLoad);
        PiwikConfig::getInstance()->forceSave();

        $this->clearCache($pluginName);

        /**
         * Event triggered after a plugin has been activated.
         *
         * @param string $pluginName The plugin that has been activated.
         */
        Piwik::postEvent('PluginManager.pluginActivated', array($pluginName));
    }
786224
public function whereTitle($title, callable $callback = null)
    {
        $item = $this->findBy('title', $title);

        if (is_callable($callback)) {
            return call_user_func($callback, $item);
        }

        return $item;
    }
261581
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;
    }
686620
public function getCompatibleProviderId($providerName, $title, $mode, $script, Map $map)
    {
        $parameters = $this->compatibleFetcher->getChoicesByPriority($title, $mode, $script);

        foreach ($parameters as $parameter) {
            $parameter = array_merge([$providerName], $parameter);
            $id = AssociativeArray::getFromKey($this->providersByCompatibility, $parameter);
            if (!is_null($id)) {
                $provider = $this->container->get($id);
                if ($provider instanceof CompatibilityCheckDataProviderInterface) {
                    if ($provider->isCompatible($map)) {
                        return $id;
                    }
                } else {
                    return $id;
                }
            }
        }

        return null;
    }
1210338
public function addElement($title, $description, $image = '')
    {
        $element = new Element($title, $description, $image);
        $this->add($element);

        return $element;
    }
1253742
function resolvePlugin(item) {
    /**
     * Handle when string was given, such as plugins: ['bs-html-injector']
     */
    if (typeof item === "string") {
        return getFromString(item);
    }

    if (!isMap(item)) {
        return new Plugin().mergeDeep({
            errors: [new Error("Plugin not supported in this format")]
        });
    }

    if (item.has("module")) {
        var nameOrObj = item.get("module");
        var options = item.get("options");

        /**
         * The 'module' key can be a string, this allows
         * inline plugin references, but with options
         * eg:
         *
         * bs.init({
         *     plugins: [
         *         {
         *             module: './myjs-file.js'
         *             options: {
         *                 files: "*.html"
         *             }
         *         }
         *     ]
         * });
         */
        if (typeof nameOrObj === "string") {
            return getFromString(nameOrObj).mergeDeep({
                options: options
            });
        }

        /**
         * If the plugin was given completely inline (because it needs options)
         * eg:
         *
         * bs.init({
         *     plugins: [
         *         {
         *             module: {
         *                 plugin: function() {
         *                     console.log('My plugin code')
         *                 }
         *             },
         *             options: {
         *                 files: "*.html"
         *             }
         *         }
         *     ]
         * })
         */
        if (Immutable.Map.isMap(nameOrObj)) {
            return new Plugin({
                module: nameOrObj,
                options: options
            });
        }
    }

    /**
     * If a module was given directly. For example, ater calling require.
     *
     * eg:
     *    var myplugin = require('./some-js');
     *    bs.init({plugins: [myplugin]});
     */
    if (item.has("plugin")) {
        return new Plugin({
            module: item
        });
    }

    /**
     * If we reach here, the plugin option was used incorrectly
     */
    return new Plugin().mergeDeep({
        errors: [new Error("Plugin was not configured correctly")]
    });
}
656382
public function get_plugin_view(string $path, string $mode, array $data, string $plugin){
    if ( !router::is_mode($mode) ){
      die("Incorrect mode $path $mode");
    }
    if (
      ($name = $this->plugin_name($plugin)) &&
      ($file = $this->router->route($path, $mode, BBN_APP_PATH.'plugins/'.$name.'/'.$mode.'/'))
    ){
      $view = new mvc\view($file);
      if ( $view->check() ){
        return \is_array($data) ? $view->get($data) : $view->get();
      }
      return '';
    }
  }
716357
public PluginDescriptor loadPlugin(Plugin plugin)
			throws MojoExecutionException {
		try {
			final Object repositorySessionObject = this.getRepositorySessionMethod.invoke(this.session);
			return (PluginDescriptor) this.loadPluginMethod.invoke(
					this.buildPluginManager,
					plugin,
					getSession().getCurrentProject().getRemotePluginRepositories(),
					repositorySessionObject);
		} catch (IllegalAccessException | IllegalArgumentException
				| InvocationTargetException e) {
			throw new MojoExecutionException(e.getLocalizedMessage(), e);
		}
	}
923697
public static function create(string $title, string $link, string $description): self
    {
        return new self($title, $link, $description);
    }
1337731
public function add($name, $code, $title)
	{
		$templates = $this->getTemplates();
		$templates->add($name, $this->plugin->name, $code, $title);
	}
822879
void setPluginPassiveScannerEnabled(int pluginId, boolean enabled) {
        PluginPassiveScanner scanner = getPluginPassiveScanner(pluginId);
        if (scanner != null) {
            scanner.setEnabled(enabled);
            scanner.save();
        }
    }