当前位置: 首页>>代码示例>>PHP>>正文


PHP Q_Config::save方法代码示例

本文整理汇总了PHP中Q_Config::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Config::save方法的具体用法?PHP Q_Config::save怎么用?PHP Q_Config::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q_Config的用法示例。


在下文中一共展示了Q_Config::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: installPlugin

 /**
  * @method installPlugin
  * @static
  * @param {string} $plugin_name
  * @param {array} $options
  * @throws {Exception}
  */
 static function installPlugin($plugin_name, $options)
 {
     set_time_limit(Q_Config::expect('Q', 'install', 'timeLimit'));
     // Connect Qbix platform if it's not already connected
     self::prepare();
     $app_dir = APP_DIR;
     $plugin_dir = Q_PLUGINS_DIR . DS . $plugin_name;
     $app_web_plugins_dir = APP_WEB_DIR . DS . 'plugins';
     echo "Installing plugin '{$plugin_name}' into '{$app_dir}'" . PHP_EOL;
     // Do we even have such a plugin?
     if (!is_dir($plugin_dir)) {
         throw new Exception("Plugin '{$plugin_name}' not found in " . Q_PLUGINS_DIR);
     }
     // Ensure that the plugin has config.json
     if (!file_exists($plugin_conf_file = $plugin_dir . DS . 'config' . DS . 'plugin.json')) {
         throw new Exception("Could not load plugin's config. Check {$plugin_conf_file}");
     }
     $files_dir = $plugin_dir . DS . 'files';
     $app_plugins_file = APP_LOCAL_DIR . DS . 'plugins.json';
     // Check access to $app_web_plugins_dir
     if (!file_exists($app_web_plugins_dir)) {
         if (!@mkdir($app_web_plugins_dir, 0755, true)) {
             throw new Exception("Could not create {$app_web_plugins_dir}");
         }
     }
     if (!is_dir($app_web_plugins_dir)) {
         throw new Exception("{$app_web_plugins_dir} exists, but is not a directory");
     } elseif (!is_writable($app_web_plugins_dir)) {
         throw new Exception("Can not write to {$app_web_plugins_dir}");
     }
     // Check access to $app_plugins_file
     if (file_exists($app_plugins_file) && !is_writable($app_plugins_file)) {
         throw new Exception("Can not write to {$app_plugins_file}");
     } elseif (!file_exists($app_plugins_file) && !is_writable(dirname($app_plugins_file))) {
         throw new Exception("Can not write to " . dirname($app_plugins_file));
     }
     // Check access to $files_dir
     if (!file_exists($files_dir)) {
         if (!@mkdir($files_dir, $options['dirmode'], true)) {
             throw new Exception("Could not create {$files_dir}");
         }
     }
     // Do we now have plugin's config?
     if (Q_Config::get('Q', 'pluginInfo', $plugin_name, 'version', null) == null) {
         throw new Exception("Could not identify plugin version. Check {$plugin_conf_file}");
     }
     $plugin_conf = Q_Config::get('Q', 'pluginInfo', $plugin_name, null);
     $plugin_version = $plugin_conf['version'];
     if (file_exists($app_plugins_file)) {
         Q_Config::load($app_plugins_file, true);
     }
     //  Do we already have this plugin installed for this app?
     // Check requirements for plugin (will throw exceptions if they aren't met)
     if (!isset($options['noreq']) || !$options['noreq']) {
         echo "Checking requirements" . PHP_EOL;
         Q_Bootstrap::checkRequirements(array($plugin_name));
     }
     //  Checking LOCAL plugin version in plugins.json file
     if (($version_installed = Q_Config::get('Q', 'pluginLocal', $plugin_name, 'version', null)) != null) {
         //We have this plugin installed
         echo "Plugin '{$plugin_name}' (version: {$version_installed}) is already installed" . PHP_EOL;
         if (Q::compare_version($version_installed, $plugin_version) < 0) {
             echo "Upgrading '{$plugin_name}' to version: {$plugin_version}" . PHP_EOL;
         }
     }
     // Check and fix permissions
     self::checkPermissions($files_dir, $options);
     if (isset($plugin_conf['permissions'])) {
         foreach ($plugin_conf['permissions'] as $perm) {
             self::checkPermissions($files_dir . DS . $perm, $options);
         }
     }
     // Symbolic links
     echo 'Creating symbolic links' . PHP_EOL;
     self::symlink($plugin_dir . DS . 'web', $app_web_plugins_dir . DS . $plugin_name);
     //  Checking if schema update is requested and updating database version
     $connections = Q_Config::get('Q', 'pluginInfo', $plugin_name, 'connections', array());
     foreach ($connections as $connection) {
         self::installSchema(Q_PLUGINS_DIR . DS . $plugin_name, $plugin_name, 'plugin', $connection, $options);
     }
     // Push plugin name into Q/plugins array
     if (!in_array($plugin_name, $current_plugins = Q_Config::get('Q', 'plugins', array()))) {
         $current_plugins[] = $plugin_name;
         Q_Config::set('Q', 'plugins', $current_plugins);
         //TODO: When do we save Q/plugins to disk?
     }
     // Save info about plugin
     echo 'Registering plugin' . PHP_EOL;
     Q_Config::set('Q', 'pluginLocal', $plugin_name, $plugin_conf);
     Q_Config::save($app_plugins_file, array('Q', 'pluginLocal'));
     echo Q_Utils::colored("Plugin '{$plugin_name}' successfully installed" . PHP_EOL, 'green');
 }
开发者ID:atirjavid,项目名称:Platform,代码行数:99,代码来源:Plugin.php


注:本文中的Q_Config::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。