/** * Disable an application. * * @param string $applicationName The name of the application to disable. * @throws \Exception Throws an exception if the application can't be disabled. */ public function disableApplication($applicationName) { $addon = $this->addonManager->lookupAddon($applicationName); if (!$addon) { throw notFoundException('Application'); } $applicationName = $addon->getRawKey(); // 1. Check to make sure that this application is allowed to be disabled if (!$addon->getInfoValue('allowDisable', true)) { throw new Exception(sprintf(t('You cannot disable the %s application.'), $applicationName)); } // 2. Check to make sure that no other enabled applications rely on this one. try { $this->addonManager->checkDependants($addon, true); } catch (Exception $ex) { throw new Gdn_UserException($ex->getMessage(), $ex->getCode()); } // 2. Disable it removeFromConfig("EnabledApplications.{$applicationName}"); Logger::event('addon_disabled', Logger::NOTICE, 'The {addonName} application was disabled.', array('addonName' => $applicationName)); // Clear the object caches. $this->addonManager->stopAddonsByKey([$applicationName], \Vanilla\Addon::TYPE_ADDON); }