Update the applications bootstrap.php file.

@param string $plugin Name of plugin.
@return bool If modify passed.
164928
protected function _modifyBootstrap($plugin)
    {
        $finder = "@\nPlugin::load\((.|.\n|\n\s\s|\n\t|)+'$plugin'(.|.\n|)+\);\n@";

        $bootstrap = new File($this->bootstrap, false);
        $content = $bootstrap->read();

        if (!preg_match("@\n\s*Plugin::loadAll@", $content)) {
            $newContent = preg_replace($finder, '', $content);

            if ($newContent === $content) {
                return false;
            }

            $bootstrap->write($newContent);

            $this->out('');
            $this->out(sprintf('%s modified', $this->bootstrap));

            return true;
        }

        return false;
    }
947089
public function check(PluginBundle $plugin)
    {
        $this->plugin = $plugin;
        $this->pluginFqcn = get_class($plugin);
        $this->errors = array();
        $this->checkRoutingPrefixIsValid();
        count($this->errors) === 0 && $this->checkRoutingPrefixIsNotAlreadyRegistered();
        $this->checkRoutingResourcesAreLoadable();

        return $this->errors;
    }
87940
public function main($plugin = null)
    {
        $filename = 'bootstrap';
        if ($this->params['cli']) {
            $filename .= '_cli';
        }

        $this->bootstrap = ROOT . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $filename . '.php';

        if (!$plugin) {
            $this->err('You must provide a plugin name in CamelCase format.');
            $this->err('To load an "Example" plugin, run `cake plugin load Example`.');

            return false;
        }

        $options = $this->makeOptions();

        $app = APP . 'Application.php';
        if (file_exists($app) && !$this->param('no_app')) {
            $this->modifyApplication($app, $plugin, $options);

            return true;
        }

        return $this->_modifyBootstrap($plugin, $options);
    }
48931
protected function getPlugin($plugin)
    {
        $path = $this->plugin->getPublicDirectory() . '/plugins/' . $plugin;
        
        if (file_exists($path) && is_dir($path)) {
            $files = scandir($path);
            
            foreach ($files as $file) {
                $pattern = defined('HHVM_VERSION') ? '/\.(php|hh)$/' : '/\.php$/';
                
                if (preg_match($pattern, $file)) {
                    $content = file_get_contents($path . '/' . $file);
                    
                    if (preg_match('/\/\*(?!.*\*\/.*Plugin Name).*Plugin Name/si', $content)) {
                        return $plugin . '/' . $file;
                    }
                }
            }
        }
        
        if (file_exists($path . '.php')) {
            return $plugin . '.php';
        }
        
        if (defined('HHVM_VERSION') && file_exists($path . '.hh')) {
            return $plugin . '.hh';
        }
        
        return false;
    }
171533
public static function update_plugins($updates) {
		// Most of the time we don't actually need to do anything.
		if (
			! \is_object($updates) ||
			! isset($updates->response) ||
			isset($updates->response['blob-common/index.php']->new_version) ||
			(false === ($me = static::check_plugin())) ||
			! $me['Version'] ||
			! $me['DownloadVersion'] ||
			! $me['DownloadURI'] ||
			\version_compare($me['Version'], $me['DownloadVersion']) >= 0
		) {
			return $updates;
		}

		// Add ourselves to the list!
		$updates->response[static::PLUGIN_PATH] = new stdClass();
		$updates->response[static::PLUGIN_PATH]->id = 0;
		$updates->response[static::PLUGIN_PATH]->new_version = $me['DownloadVersion'];
		$updates->response[static::PLUGIN_PATH]->package = $me['DownloadURI'];
		$updates->response[static::PLUGIN_PATH]->plugin = 'blob-common/index.php';
		$updates->response[static::PLUGIN_PATH]->slug = $me['TextDomain'];
		$updates->response[static::PLUGIN_PATH]->url = $me['PluginURI'];

		return $updates;
	}
926190
public function disableAction(Plugin $plugin)
    {
        $this->pluginManager->disable($plugin);

        return new JsonResponse(
            $this->pluginManager->getPluginsData()
        );
    }
371260
protected function checkSimple($plugin)
    {
        return ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $plugin .
            DIRECTORY_SEPARATOR . $this->getNamespace($plugin) . '.php';
    }
73418
private function installPluginIfNecessary(Plugin $plugin)
    {
        $pluginName = $plugin->getPluginName();
        $saveConfig = false;

        // is the plugin already installed or is it the first time we activate it?
        $pluginsInstalled = $this->getInstalledPluginsName();

        if (!$this->isPluginInstalled($pluginName)) {
            $this->executePluginInstall($plugin);
            $pluginsInstalled[] = $pluginName;
            $this->updatePluginsInstalledConfig($pluginsInstalled);
            $updater = new Updater();
            $updater->markComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion(), $isNew = true);
            $saveConfig = true;

            /**
             * Event triggered after a new plugin has been installed.
             *
             * Note: Might be triggered more than once if the config file is not writable
             *
             * @param string $pluginName The plugin that has been installed.
             */
            Piwik::postEvent('PluginManager.pluginInstalled', array($pluginName));
        }

        if ($saveConfig) {
            PiwikConfig::getInstance()->forceSave();
            $this->clearCache($pluginName);
        }
    }
945531
protected function modifyApplication($app, $plugin, $options)
    {
        $file = new File($app, false);
        $contents = $file->read();

        $append = "\n        \$this->addPlugin('%s', [%s]);\n";
        $insert = str_replace(', []', '', sprintf($append, $plugin, $options));

        if (!preg_match('/function bootstrap\(\)/m', $contents)) {
            $this->abort('Your Application class does not have a bootstrap() method. Please add one.');
        } else {
            $contents = preg_replace('/(function bootstrap\(\)(?:\s+)\{)/m', '$1' . $insert, $contents);
        }
        $file->write($contents);

        $this->out('');
        $this->out(sprintf('%s modified', $app));
    }
1063084
public function unloadPlugin($plugin)
    {
        $this->resetTransientCache();

        if (!($plugin instanceof Plugin)) {
            $oPlugin = $this->loadPlugin($plugin);
            if ($oPlugin === null) {
                unset($this->loadedPlugins[$plugin]);
                return;
            }

            $plugin = $oPlugin;
        }

        unset($this->loadedPlugins[$plugin->getPluginName()]);
    }
439960
public function update(PluginBundleInterface $plugin, $currentVersion, $targetVersion)
    {
        $this->checkInstallationStatus($plugin, true);

        $this->baseInstaller->update($plugin, $currentVersion, $targetVersion);

        // updates plugin version
        $this->versionManager->setLogger($this->logger);
        $version = $this->versionManager->register($plugin);
        $this->versionManager->execute($version);
    }
425837
public function appendPlugin(Plugin ...$plugin): self
    {
        foreach ($plugin as $p) {
            $this->appendPlugins[] = $p;
        }

        return $this;
    }
522710
public function installPluginIntoMoodle(MoodlePlugin $plugin)
    {
        $this->getOutput()->info(sprintf('Installing %s', $plugin->getComponent()));

        $directory = $this->moodle->getComponentInstallDirectory($plugin->getComponent());

        if (is_dir($directory)) {
            throw new \RuntimeException('Plugin is already installed in standard Moodle');
        }

        $this->getOutput()->info(sprintf('Copying plugin from %s to %s', $plugin->directory, $directory));

        // Install the plugin.
        $filesystem = new Filesystem();
        $filesystem->mirror($plugin->directory, $directory);

        return $directory;
    }
45548
public function processInstallScript(Plugin $plugin, &$log)
    {
        $script = $plugin->Path .'/install.php';
        if(file_exists($script)) {
            include_once $script;
        }
    }
794954
private function updatePluginsConfig($pluginsToLoad)
    {
        $pluginsToLoad = $this->pluginList->sortPluginsAndRespectDependencies($pluginsToLoad);
        $section = PiwikConfig::getInstance()->Plugins;
        $section['Plugins'] = $pluginsToLoad;
        PiwikConfig::getInstance()->Plugins = $section;
    }
1015858
public function isSaved(PluginBundle $plugin)
    {
        if ($this->getPluginByFqcn(get_class($plugin)) !== null) {
            return true;
        }

        return false;
    }
946322
public function update(PluginBundleInterface $plugin, $currentVersion, $targetVersion)
    {
        $this->checkInstallationStatus($plugin, true);
        $this->validator->activeUpdateMode();
        $this->validatePlugin($plugin);
        $this->validator->deactivateUpdateMode();
        $this->log('Updating plugin configuration...');
        $this->baseInstaller->update($plugin, $currentVersion, $targetVersion);
        $this->recorder->update($plugin, $this->validator->getPluginConfiguration());
    }