/** * Attempt to retreive addon config file for given addon * * @param array|string $addon * * @return bool|string */ public function getAddonConfigFile($addon) { // Convert string to the array input we're expecting if (is_string($addon)) { $addon = array('addon_id' => $addon, 'title' => $addon); } // Validate input if (!is_array($addon) or !isset($addon['addon_id'], $addon['title'])) { return false; } // Define the addon folder names we will be checking for $names = array($addon['addon_id'], strtolower($addon['addon_id']), XDT_CLI_Helper::camelcaseString($addon['addon_id'], false), XDT_CLI_Helper::camelcaseString($addon['title'], false)); // If title contains the '-' character, turn it into folder bits $bits = explode('-', $addon['title']); if (count($bits) > 1) { foreach ($bits as &$bit) { $bit = XDT_CLI_Helper::camelcaseString($bit, false); } $names[] = implode('/', $bits); $names[] = strtolower(implode('/', $bits)); } // Set variations (with and without library folder) $variations = array(); foreach ($names as $name) { $variations = array_merge($variations, array($name, 'library/' . $name)); } // Locate the config file $base = XDT_CLI_Application::xfBaseDir(); return XDT_CLI_Helper::locate('.xfcli-config', $variations, $base, array($base)); }
/** * Get config from filesystem * * @return Object */ public static function getConfig() { $config = XenForo_Application::getConfig(); $addonConfig = array('addon_id' => $config->xdt->addon_id, 'name' => $config->xdt->name, 'namespace' => $config->xdt->namespace, 'path' => $config->xdt->path, 'addon_config' => $config->xdt->addon_config, 'file_mask' => '0644', 'dir_mask' => '0755'); return $addonConfig; if (!empty(self::$_config)) { return self::$_config; } $ds = DIRECTORY_SEPARATOR; $up = '..' . $ds; $config = self::loadConfigJson(dirname(__FILE__) . $ds . $up . $up . '.xfcli-config'); // TODO: ability to overwrite this with --addon-config=path option. Useful for one off changes to something $config = XDT_CLI_Helper::objectMerge($config, self::loadConfigJson(self::xfBaseDir() . '.xfcli-config')); if (!empty($config->addon_config)) { $file = XDT_CLI_Helper::locate($config->addon_config, array('library'), null, array(self::xfBaseDir())); if ($file) { $config = XDT_CLI_Helper::objectMerge($config, self::loadConfigJson($file)); } } return $config; }