/** * activate httpCache-Plugin * @param Plugin $httpCache */ private function activeHttpCache($httpCache) { /**@var $service InstallerService*/ $service = Shopware()->Container()->get('shopware.plugin_manager'); if (!$httpCache->getInstalled()) { $service->installPlugin($httpCache); } if (!$httpCache->getActive()) { $service->activatePlugin($httpCache); } }
/** * @param Plugin $plugin * @throws \Exception */ public function activatePlugin(Plugin $plugin) { if ($plugin->getActive()) { return; } if (!$plugin->getInstalled()) { throw new \Exception('Plugin has to be installed first.'); } $bootstrap = $this->getPluginBootstrap($plugin); $result = $bootstrap->enable(); $result = is_bool($result) ? ['success' => $result] : $result; if ($result['success'] == false) { throw new \Exception('Not allowed to enable plugin.'); } $plugin->setActive(true); $this->em->flush($plugin); return $result; }
/** * @param Plugin $plugin * @throws \Exception */ public function activatePlugin(Plugin $plugin) { if ($plugin->getActive()) { return; } if (!$plugin->getInstalled()) { throw new \Exception('Plugin has to be installed first.'); } $bootstrap = $this->getPluginBootstrap($plugin); $isAllowed = $bootstrap->enable(); $isAllowed = is_bool($isAllowed) ? $isAllowed : !empty($isAllowed['success']); if (!$isAllowed) { throw new \Exception('Not allowed to enable plugin.'); } $plugin->setActive(true); $this->em->flush($plugin); }