/** * Enable an addon and do all the stuff that's entailed there. * * @param Addon $addon The addon to enable. * @param bool $setup Whether or not to set the plugin up. * @throws Exception Throws an exception if something goes bonkers during the process. */ private function enableAddon(Addon $addon, $setup) { if ($setup) { $this->addonManager->startAddon($addon); $this->pluginHook($addon->getRawKey(), self::ACTION_ENABLE, true); // If setup succeeded, register any specified permissions $permissions = $addon->getInfoValue('registerPermissions'); if (!empty($permissions)) { $PermissionModel = Gdn::permissionModel(); $PermissionModel->define($permissions); } // Write enabled state to config. saveToConfig("EnabledPlugins." . $addon->getRawKey(), true); Logger::event('addon_enabled', Logger::INFO, 'The {addonName} plugin was enabled.', array('addonName' => $addon->getRawKey())); } $pluginClassName = $addon->getPluginClass(); $this->registerPlugin($pluginClassName); }