getInstalled example

$pluginManager = $this->container->get(InstallerService::class);
        $pluginName = $input->getArgument('plugin');

        try {
            $plugin = $pluginManager->getPluginByName($pluginName);
        } catch (Exception $e) {
            $output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));

            return 1;
        }

        if (!$plugin->getInstalled()) {
            $output->writeln(sprintf('The plugin %s is already uninstalled.', $pluginName));

            return 1;
        }

        $removeData = !(bool) $input->getOption('secure');

        $uninstallationContext = $pluginManager->uninstallPlugin($plugin$removeData);
        $output->writeln(sprintf('Plugin %s has been uninstalled successfully.', $pluginName));

        $this->clearCachesIfRequested($input$output$uninstallationContext);

        

    protected $configData = [];

    /** * get productive mode */
    public function getProductiveModeAction()
    {
        $httpCache = $this->getPluginByName('HttpCache');

        $active = $httpCache->getActive() && $httpCache->getInstalled() != null;

        $this->View()->assign([
            'success' => true,
            'productiveMode' => $active,
        ]);
    }

    /** * Set productive mode true or false * Enable and disable caching by enable or disable plugin 'HttpCache' */
    
private static $installedByVendor = array();

    /** * Returns a list of all package names which are present, either by being installed, replaced or provided * * @return string[] * @psalm-return list<string> */
    public static function getInstalledPackages()
    {
        $packages = array();
        foreach (self::getInstalled() as $installed) {
            $packages[] = array_keys($installed['versions']);
        }

        if (1 === \count($packages)) {
            return $packages[0];
        }

        return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
    }

    /** * Returns a list of all package names with a specific type e.g. 'library' * * @param string $type * @return string[] * @psalm-return list<string> */

    protected function HttpCache()
    {
        $httpCache = Shopware()->Plugins()->Core()->HttpCache();

        if (!$httpCache instanceof self) {
            return null;
        }

        $plugin = Shopware()->Models()->find(Plugin::class$httpCache->getId());

        if (!$plugin instanceof Plugin || !$plugin->getActive() || !$plugin->getInstalled()) {
            return null;
        }

        return $httpCache;
    }

    /** * Check if a list of given plugins is currently available * and active * * @return bool */
$technicalName = $this->Request()->getParam('technicalName');

        $plugin = $this->getPluginModel($technicalName);

        // disable plugin and save state         $active = $plugin->getActive();
        $plugin->setActive(false);
        $this->get(ModelManager::class)->flush();

        try {
            if ($plugin->getInstalled()) {
                $result = $this->pluginManager->updatePlugin($plugin);
            } else {
                $result = $this->pluginManager->installPlugin($plugin);
            }
        } catch (Exception $e) {
            $this->View()->assign([
                'success' => false,
                'message' => $e->getMessage(),
            ]);

            return;
        }


        $rows = [];

        foreach ($plugins as $plugin) {
            $rows[] = [
                $plugin->getName(),
                $plugin->getLabel(),
                $plugin->getVersion(),
                $plugin->getAuthor(),
                $plugin->getActive() ? 'Yes' : 'No',
                $plugin->getInstalled() ? 'Yes' : 'No',
            ];
        }

        $table = new Table($output);
        $table->setHeaders(['Plugin', 'Label', 'Version', 'Author', 'Active', 'Installed'])
              ->setRows($rows);

        $table->render();

        return 0;
    }
}
try {
            $plugin = $pluginManager->getPluginByName($pluginName);
        } catch (Exception $e) {
            $output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));

            return 1;
        }

        $installationContext = null;

        if ($plugin->getInstalled()) {
            $output->writeln(sprintf('The plugin %s is already installed.', $pluginName));
        } else {
            $installationContext = $pluginManager->installPlugin($plugin);
            $output->writeln(sprintf('Plugin %s has been installed successfully.', $pluginName));
        }

        $activationContext = null;

        if ($input->getOption('activate')) {
            $activationContext = $pluginManager->activatePlugin($plugin);
            $output->writeln(sprintf('Plugin %s has been activated successfully.', $pluginName));
        }
if (!$pluginBootstrap instanceof Enlight_Plugin_Bootstrap) {
            return null;
        }

        /** @var Plugin|null $plugin */
        $plugin = $this->get('models')->find(Plugin::class$pluginBootstrap->getId());
        if (!$plugin) {
            return null;
        }

        if (!$plugin->getActive() || !$plugin->getInstalled()) {
            return null;
        }

        return $pluginBootstrap;
    }
}
return $this->legacyPluginInstaller->getPluginBootstrap($plugin);
    }

    /** * @throws Exception * * @return InstallContext */
    public function installPlugin(Plugin $plugin)
    {
        $context = new InstallContext($plugin$this->release->getVersion()$plugin->getVersion());
        if ($plugin->getInstalled()) {
            return $context;
        }

        if (!$plugin->isLegacyPlugin()) {
            return $this->pluginInstaller->installPlugin($plugin);
        }

        $result = $this->legacyPluginInstaller->installPlugin($plugin);
        $this->applyLegacyResultToContext($result$context);

        return $context;
    }
$pluginRepository = $this->em->getRepository(Plugin::class);

        foreach ($requiredPlugins as $requiredPlugin) {
            $plugin = $pluginRepository->findOneBy([
                'name' => $requiredPlugin['pluginName'],
            ]);

            if (!$plugin) {
                throw new Exception(sprintf($this->namespace->get('required_plugin_not_found')$requiredPlugin['pluginName']));
            }

            if ($plugin->getInstalled() === null) {
                throw new Exception(sprintf($this->namespace->get('required_plugin_not_installed')$requiredPlugin['pluginName']));
            }

            if (!$plugin->getActive()) {
                throw new Exception(sprintf($this->namespace->get('required_plugin_not_active')$requiredPlugin['pluginName']));
            }

            if (isset($requiredPlugin['blacklist']) && \in_array($plugin->getVersion()$requiredPlugin['blacklist'])) {
                throw new Exception(sprintf($this->namespace->get('required_plugin_blacklisted')$plugin->getName()$plugin->getVersion()));
            }

            
$pluginManager = $this->container->get(InstallerService::class);
        $pluginName = $input->getArgument('plugin');

        try {
            $plugin = $pluginManager->getPluginByName($pluginName);
        } catch (Exception $e) {
            $output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));

            return 1;
        }

        if ($plugin->getInstalled()) {
            $output->writeln('The Plugin has to be uninstalled first.');

            return 1;
        }

        $pluginPath = $pluginManager->getPluginPath($pluginName);

        $message = null;
        if ($plugin->getSource() === 'Default') {
            $message = "'Default' Plugins may not be deleted.";
        } elseif (!$this->deletePath($pluginPath)) {
            
$output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));

            return 1;
        }

        if ($plugin->getActive()) {
            $output->writeln(sprintf('The plugin %s is already activated.', $pluginName));

            return 0;
        }

        if (!$plugin->getInstalled()) {
            $output->writeln(sprintf('The plugin %s has to be installed first.', $pluginName));

            return 1;
        }

        $activationContext = $pluginManager->activatePlugin($plugin);
        $output->writeln(sprintf('Plugin %s has been activated.', $pluginName));

        $this->clearCachesIfRequested($input$output$activationContext);

        return 0;
    }
Home | Imprint | This part of the site doesn't use cookies.