{@inheritdoc}

@throws PluginNotInstalledException
@throws PluginNotActivatedException
6994
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $context = Context::createDefaultContext();
        $plugins = $this->prepareExecution(self::LIFECYCLE_METHOD, $io, $input, $context);

        $deactivatedPluginCount = 0;
        /** @var PluginEntity $plugin */
        foreach ($plugins as $plugin) {
            if ($plugin->getInstalledAt() === null) {
                $io->note(sprintf('Plugin "%s" must be installed. Skipping.', $plugin->getName()));

                continue;
            }

            if ($plugin->getActive() === false) {
                $io->note(sprintf('Plugin "%s" must be activated. Skipping.', $plugin->getName()));

                continue;
            }

            $this->pluginLifecycleService->deactivatePlugin($plugin, $context);
            ++$deactivatedPluginCount;

            $io->text(sprintf('Plugin "%s" has been deactivated successfully.', $plugin->getName()));
        }

        if ($deactivatedPluginCount !== 0) {
            $io->success(sprintf('Deactivated %d plugin(s).', $deactivatedPluginCount));
        }
    }
605765
protected function initialize()
    {
        // Sanity check; must be on (or after) `plugins_loaded` hook.
        // If uninstalling, must be on (or after) `init` hook.

        if (!did_action('plugins_loaded')) {
            throw new Exception('`plugins_loaded` action not done yet.');
        } elseif ($this->Config->§uninstall && !did_action('init')) {
            throw new Exception('`init` action not done yet.');
        }
        // Check for any known conflicts.

        if ($this->s::conflictsExist()) {
            return; // Stop here.
        }
        // Check for any unsatisfied dependencies.

        if ($this->s::dependenciesUnsatisfied()) {
            return; // Stop here.
        }
        // Add app instance to collection.

        if ($this->Parent && $this->Parent->is_core && !$this->Config->§uninstall) {
            $this->Parent->s::addApp($this);
        }
        // Remaining routines are driven by setup hook.

        if ($this->Config->§uninstall || did_action($this->Config->§setup['§hook'])) {
            $this->onSetup(); // Run setup immediately.
        } else { // Delay setup routines; i.e., attach to hook.
            add_action($this->Config->§setup['§hook'], [$this, 'onSetup'], $this->Config->§setup['§hook_priority']);
        }
    }
614888
public function activatePlugins(): void
    {
        foreach (array_keys($this->getPlugins()) as $plugin) {
            if (!$this->isPluginActive($plugin)) {
                $this->activatePlugin($plugin);
            }
        }
    }
93556
private function savePlugin(string $handle, array $definition, array $pluginInfo): bool
    {
        if (!$pluginInfo['isInstalled']) {
            Craft::$app->plugins->installPlugin($handle);
        }
        if ($definition['isEnabled']) {
            Craft::$app->plugins->enablePlugin($handle);
        } else {
            Craft::$app->plugins->disablePlugin($handle);
        }
        $plugin = Craft::$app->plugins->getPlugin($handle);

        if ($plugin && $plugin->getSettings()) {
            return Craft::$app->plugins->savePluginSettings($plugin, $definition['settings']);
        }

        return false;
    }
1274880
public EmbeddedGobblin usePlugin(String pluginAlias) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
    return usePlugin(GobblinInstancePluginUtils.instantiatePluginByAlias(pluginAlias));
  }
769030
public function update(PluginBundle $pluginBundle, array $pluginConfiguration)
    {
        /** @var Plugin $plugin */
        $plugin = $this->em->getRepository('ClarolineCoreBundle:Plugin')->findOneBy(
            array(
                 'vendorName' => $pluginBundle->getVendorName(),
                 'bundleName' => $pluginBundle->getBundleName()
            )
        );

        if (null === $plugin) {
            throw new \Exception('Unable to retrieve plugin for updating its configuration.');
        }

        $plugin->setHasOptions($pluginConfiguration['has_options']);

        $this->em->persist($plugin);
        $this->updateConfiguration($pluginConfiguration, $plugin, $pluginBundle);
        $this->em->flush();
    }
849453
protected function _init()
    {
        if (!parent::_init()) {
            return false;
        }

        if (!Plugin::exists($this->_plugin['name'])) {
            $this->err(__d('installer', 'The plugin "{0}" is not installed, you cannot update a plugin that is not installed in your system.', $this->_plugin['name']));

            return false;
        } else {
            $plugin = plugin($this->_plugin['name']);
            if (!$this->canBeDeleted($plugin->path)) {
                $this->err(__d('installer', 'Unable to update, please check write permissions for "{0}".', $plugin->path));

                return false;
            }
        }

        return true;
    }
1243265
public function Refresh() {
      $LocalName = $this->Current();
      
      $ApplicationWhiteList = Gdn::ApplicationManager()->EnabledApplicationFolders();
      $PluginWhiteList = Gdn::PluginManager()->EnabledPluginFolders();

      $ForceRemapping = TRUE;

      $this->Set($LocalName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping);
   }
787132
private function createPluginsNode(ArrayNodeDefinition $rootNode): void
    {
        $pluginsNode = $rootNode
            ->children()
                ->arrayNode('plugins')
                ->children();

        foreach ($this->plugins as $plugin) {
            $pluginNode = new ArrayNodeDefinition($plugin->getPluginName());
            $plugin->addConfiguration($pluginNode);

            $pluginsNode->append($pluginNode);
        }
    }
899019
protected function updatePluginData()
    {
        $this->pluginBaseName = \plugin_basename($this->pluginFile);
        $this->pluginSlug = dirname($this->pluginBaseName);
        $this->pluginData = \get_plugin_data($this->pluginFile);
    }
220450
private function canInstall()
    {
        $this->info("Validating");

        // Exists as a directory
        if(!file_exists(pluginsPath($this->pluginNamespace))) {
            throw new \Exception("Plugin ".$this->pluginNamespace." not found in plugins directory!");
        }

        // Remove composer autoloader
        exec('composer dump-autoload', $output, $return_var);

        // Clear laravel compiled files
        $this->callSilent('clear-compiled');

        // Plugin class exists
        $fullNamespace =  'Plugins\\'.str_replace('/', '\\', $this->pluginNamespace.'\\Plugin');

        if(!class_exists($fullNamespace)) {
            // When composer autoload was generated, we didn't have this plugin's classes
            // that's why we have to autoload all Plugin' classes manually
            spl_autoload_register(
                function ($class) {
                    $class = str_replace("\\", "/", $class);
                    $class = str_replace("Plugins", "plugins", $class);
                    include base_path().'/' . $class. '.php';
                }
            );
        }

        // Make sure Plugin namespace class exist
        if(!class_exists($fullNamespace)) {
            throw new \Exception("Class $fullNamespace not found!");
        }

        // Plugin needs to have an "install" method
        $this->pluginInstance = new $fullNamespace();
        if(!method_exists($this->pluginInstance, 'install')) {
            throw new \Exception("Plugin ".$this->pluginNamespace." does not have an install method!");
        }

        // Plugin should not be in DB Table
        if(Plugin::where('namespace', $this->pluginNamespace)->first()) {
            throw new \Exception("Plugin ".$this->pluginNamespace." already exists in DB!");
        }

        // Config file exist
        if(!file_exists(pluginsPath($this->pluginNamespace.'/config.json'))) {
            throw new \Exception("Plugin ".$this->pluginNamespace." config.file does not exists!");
        }
        return true;
    }
1120215
public function setPlugins($plugins)
    {
        $this->plugins = array();
        foreach ($plugins as $key => $plugin) {
            $pluginClass = $plugin;
            if (is_array($plugin)) {
                if (!isset($plugin[Config::KEY_CLASS])) {
                    throw new PluginException('Invalid or missing class for plugin '.$key);
                } elseif (!class_exists($plugin[Config::KEY_CLASS])) {
                    throw new PluginException('Invalid or missing class for plugin '.$key);
                }
                $pluginClass = $plugin[Config::KEY_CLASS];
            }
            $options = array();
            if (isset($plugin[Config::KEY_OPTIONS])) {
                $options = (array)$plugin[Config::KEY_OPTIONS];
            }
            $this->plugins[] = new $pluginClass($options);
        }
        $this->plugins = $this->sortPlugins($this->plugins);
        return $this;
    }
160689
protected void updatePluginContainer(PluginContainer value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         iteratePlugin(innerCount, root, value.getPlugins(), "plugins", "plugin");
      }
   }
993966
public function loadPlugins(array $pluginsToLoad)
    {
        $this->resetTransientCache();
        $this->pluginsToLoad = $this->makePluginsToLoad($pluginsToLoad);
        $this->reloadActivatedPlugins();
    }
137771
public function bootPlugin($plugin)
    {
        if (!$plugin || $plugin->disabled) {
            return;
        }

        if (!self::$noInit || $plugin->elevated) {
            $plugin->boot();
        }
    }
1305292
public function uninstall(Composer $composer, IOInterface $io, $pluginName)
    {
        $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName);
        
        if ($plugin) {
            $result = $this->wp(function () use ($plugin) {
                return uninstall_plugin($plugin);
            });
            
            $this->succeeded(__FUNCTION__, $pluginName, $result === true || $result === null);
        }
    }
443950
protected function init_pluginsinfo_property() {
        if (is_array($this->pluginsinfo)) {
            return;
        }
        $this->pluginsinfo = array();

        $plugintypes = $this->get_plugin_types();

        foreach ($plugintypes as $plugintype => $plugintyperootdir) {
            $this->pluginsinfo[$plugintype] = null;
        }

        // Add orphaned subplugin types.
        $this->load_installed_plugins();
        foreach ($this->installedplugins as $plugintype => $unused) {
            if (!isset($plugintypes[$plugintype])) {
                $this->pluginsinfo[$plugintype] = null;
            }
        }
    }