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


PHP IConfig::setSystemValues方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $importFile = $input->getArgument('file');
     if ($importFile !== null) {
         $content = $this->getArrayFromFile($importFile);
     } else {
         $content = $this->getArrayFromStdin();
     }
     try {
         $configs = $this->validateFileContent($content);
     } catch (\UnexpectedValueException $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         return;
     }
     if (!empty($configs['system'])) {
         $this->config->setSystemValues($configs['system']);
     }
     if (!empty($configs['apps'])) {
         foreach ($configs['apps'] as $app => $appConfigs) {
             foreach ($appConfigs as $key => $value) {
                 if ($value === null) {
                     $this->config->deleteAppValue($app, $key);
                 } else {
                     $this->config->setAppValue($app, $key, $value);
                 }
             }
         }
     }
     $output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>');
 }
开发者ID:evanjt,项目名称:core,代码行数:30,代码来源:import.php

示例2: initialize

 public function initialize($config)
 {
     $dbUser = $config['dbuser'];
     $dbPass = $config['dbpass'];
     $dbName = $config['dbname'];
     $dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
     $dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
     $this->config->setSystemValues(['dbname' => $dbName, 'dbhost' => $dbHost, 'dbtableprefix' => $dbTablePrefix]);
     $this->dbUser = $dbUser;
     $this->dbPassword = $dbPass;
     $this->dbName = $dbName;
     $this->dbHost = $dbHost;
     $this->tablePrefix = $dbTablePrefix;
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:14,代码来源:AbstractDatabase.php

示例3: saveDBInfo

 protected function saveDBInfo(InputInterface $input)
 {
     $type = $input->getArgument('type');
     $username = $input->getArgument('username');
     $dbHost = $input->getArgument('hostname');
     $dbName = $input->getArgument('database');
     $password = $input->getOption('password');
     if ($input->getOption('port')) {
         $dbHost .= ':' . $input->getOption('port');
     }
     $this->config->setSystemValues(['dbtype' => $type, 'dbname' => $dbName, 'dbhost' => $dbHost, 'dbuser' => $username, 'dbpassword' => $password]);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:12,代码来源:converttype.php

示例4: storeCredentials

 /**
  * Store the credentials used for SMTP in the config
  * @param string $mail_smtpname
  * @param string $mail_smtppassword
  * @return array
  */
 public function storeCredentials($mail_smtpname, $mail_smtppassword)
 {
     $this->config->setSystemValues(['mail_smtpname' => $mail_smtpname, 'mail_smtppassword' => $mail_smtppassword]);
     return array('data' => array('message' => (string) $this->l10n->t('Saved')), 'status' => 'success');
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:11,代码来源:MailSettingsController.php

示例5: install

 /**
  * @param $options
  * @return array
  */
 public function install($options)
 {
     $l = $this->l10n;
     $error = array();
     $dbType = $options['dbtype'];
     if (empty($options['adminlogin'])) {
         $error[] = $l->t('Set an admin username.');
     }
     if (empty($options['adminpass'])) {
         $error[] = $l->t('Set an admin password.');
     }
     if (empty($options['directory'])) {
         $options['directory'] = \OC::$SERVERROOT . "/data";
     }
     if (!isset(self::$dbSetupClasses[$dbType])) {
         $dbType = 'sqlite';
     }
     $username = htmlspecialchars_decode($options['adminlogin']);
     $password = htmlspecialchars_decode($options['adminpass']);
     $dataDir = htmlspecialchars_decode($options['directory']);
     $class = self::$dbSetupClasses[$dbType];
     /** @var \OC\Setup\AbstractDatabase $dbSetup */
     $dbSetup = new $class($l, 'db_structure.xml', $this->config, $this->logger, $this->random);
     $error = array_merge($error, $dbSetup->validate($options));
     // validate the data directory
     if (!is_dir($dataDir) and !mkdir($dataDir) or !is_writable($dataDir)) {
         $error[] = $l->t("Can't create or write into the data directory %s", array($dataDir));
     }
     if (count($error) != 0) {
         return $error;
     }
     $request = \OC::$server->getRequest();
     //no errors, good
     if (isset($options['trusted_domains']) && is_array($options['trusted_domains'])) {
         $trustedDomains = $options['trusted_domains'];
     } else {
         $trustedDomains = [$request->getInsecureServerHost()];
     }
     if (\OC_Util::runningOnWindows()) {
         $dataDir = rtrim(realpath($dataDir), '\\');
     }
     //use sqlite3 when available, otherwise sqlite2 will be used.
     if ($dbType == 'sqlite' and class_exists('SQLite3')) {
         $dbType = 'sqlite3';
     }
     //generate a random salt that is used to salt the local user passwords
     $salt = $this->random->generate(30);
     // generate a secret
     $secret = $this->random->generate(48);
     //write the config file
     $this->config->setSystemValues(['passwordsalt' => $salt, 'secret' => $secret, 'trusted_domains' => $trustedDomains, 'datadirectory' => $dataDir, 'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT, 'dbtype' => $dbType, 'version' => implode('.', \OCP\Util::getVersion())]);
     try {
         $dbSetup->initialize($options);
         $dbSetup->setupDatabase($username);
     } catch (\OC\DatabaseSetupException $e) {
         $error[] = array('error' => $e->getMessage(), 'hint' => $e->getHint());
         return $error;
     } catch (Exception $e) {
         $error[] = array('error' => 'Error while trying to create admin user: ' . $e->getMessage(), 'hint' => '');
         return $error;
     }
     //create the user and group
     $user = null;
     try {
         $user = \OC::$server->getUserManager()->createUser($username, $password);
         if (!$user) {
             $error[] = "User <{$username}> could not be created.";
         }
     } catch (Exception $exception) {
         $error[] = $exception->getMessage();
     }
     if (count($error) == 0) {
         $config = \OC::$server->getConfig();
         $config->setAppValue('core', 'installedat', microtime(true));
         $config->setAppValue('core', 'lastupdatedat', microtime(true));
         $group = \OC::$server->getGroupManager()->createGroup('admin');
         $group->addUser($user);
         \OC_User::login($username, $password);
         //guess what this does
         \OC_Installer::installShippedApps();
         // create empty file in data dir, so we can later find
         // out that this is indeed an ownCloud data directory
         file_put_contents($config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
         // Update .htaccess files
         Setup::updateHtaccess();
         Setup::protectDataDirectory();
         //try to write logtimezone
         if (date_default_timezone_get()) {
             $config->setSystemValue('logtimezone', date_default_timezone_get());
         }
         //and we are done
         $config->setSystemValue('installed', true);
     }
     return $error;
 }
开发者ID:kenwi,项目名称:core,代码行数:99,代码来源:setup.php


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