/** * Test if an application can be enabled. * * @param string $applicationName The name of the application to test. * @return bool Returns true if the application can be enabled or false otherwise. * @throws Exception Throws an exception if the application is not in the correct format. */ public function testApplication($applicationName) { // Add the application to the $EnabledApplications array in conf/applications.php $ApplicationInfo = arrayValueI($applicationName, $this->availableApplications(), array()); $applicationName = $ApplicationInfo['Index']; $ApplicationFolder = val('Folder', $ApplicationInfo, ''); if ($ApplicationFolder == '') { throw new Exception(t('The application folder was not properly defined.')); } // Hook directly into the autoloader and force it to load the newly tested application $this->addonManager->startAddonsByKey([$applicationName], \Vanilla\Addon::TYPE_ADDON); // Call the application's setup method $hooks = $applicationName . 'Hooks'; if (!class_exists($hooks)) { $hooksPath = PATH_APPLICATIONS . DS . $ApplicationFolder . '/settings/class.hooks.php'; if (file_exists($hooksPath)) { include_once $hooksPath; } } if (class_exists($hooks)) { /* @var Gdn_IPlugin $hooks The hooks object should be a plugin. */ $hooks = new $hooks(); if (method_exists($hooks, 'setup')) { $hooks->setup(); } } return true; }