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


PHP ConfigFactory::getDefaultInstance方法代码示例

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


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

示例1: __construct

 /**
  * Creates an ImportXMLReader drawing from the source provided
  * @param ImportSource $source
  * @param Config $config
  */
 function __construct(ImportSource $source, Config $config = null)
 {
     $this->reader = new XMLReader();
     if (!$config) {
         wfDeprecated(__METHOD__ . ' without a Config instance', '1.25');
         $config = ConfigFactory::getDefaultInstance()->makeConfig('main');
     }
     $this->config = $config;
     if (!in_array('uploadsource', stream_get_wrappers())) {
         stream_wrapper_register('uploadsource', 'UploadSourceAdapter');
     }
     $id = UploadSourceAdapter::registerSource($source);
     if (defined('LIBXML_PARSEHUGE')) {
         $this->reader->open("uploadsource://{$id}", null, LIBXML_PARSEHUGE);
     } else {
         $this->reader->open("uploadsource://{$id}");
     }
     // Default callbacks
     $this->setPageCallback(array($this, 'beforeImportPage'));
     $this->setRevisionCallback(array($this, "importRevision"));
     $this->setUploadCallback(array($this, 'importUpload'));
     $this->setLogItemCallback(array($this, 'importLogItem'));
     $this->setPageOutCallback(array($this, 'finishImportPage'));
     $this->importTitleFactory = new NaiveImportTitleFactory();
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:30,代码来源:Import.php

示例2: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     $rl = new ResourceLoader(ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $moduleNames = $rl->getModuleNames();
     $moduleList = implode(', ', array_map(array($dbw, 'addQuotes'), $moduleNames));
     $limit = max(1, intval($this->getOption('batchsize', 500)));
     $this->output("Cleaning up module_deps table...\n");
     $i = 1;
     $modDeps = $dbw->tableName('module_deps');
     do {
         // $dbw->delete() doesn't support LIMIT :(
         $where = $moduleList ? "md_module NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$modDeps} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
     $this->output("Cleaning up msg_resource table...\n");
     $i = 1;
     $mrRes = $dbw->tableName('msg_resource');
     do {
         $where = $moduleList ? "mr_resource NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$mrRes} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:33,代码来源:cleanupRemovedModules.php

示例3: testSetPasswordResetFlag

 public function testSetPasswordResetFlag()
 {
     $config = new \HashConfig(['InvalidPasswordReset' => true]);
     $manager = new AuthManager(new \FauxRequest(), \ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $provider = $this->getMockForAbstractClass(AbstractPasswordPrimaryAuthenticationProvider::class);
     $provider->setConfig($config);
     $provider->setLogger(new \Psr\Log\NullLogger());
     $provider->setManager($manager);
     $providerPriv = \TestingAccessWrapper::newFromObject($provider);
     $manager->removeAuthenticationSessionData(null);
     $status = \Status::newGood();
     $providerPriv->setPasswordResetFlag('Foo', $status);
     $this->assertNull($manager->getAuthenticationSessionData('reset-pass'));
     $manager->removeAuthenticationSessionData(null);
     $status = \Status::newGood();
     $status->error('testing');
     $providerPriv->setPasswordResetFlag('Foo', $status);
     $ret = $manager->getAuthenticationSessionData('reset-pass');
     $this->assertNotNull($ret);
     $this->assertSame('resetpass-validity-soft', $ret->msg->getKey());
     $this->assertFalse($ret->hard);
     $config->set('InvalidPasswordReset', false);
     $manager->removeAuthenticationSessionData(null);
     $providerPriv->setPasswordResetFlag('Foo', $status);
     $ret = $manager->getAuthenticationSessionData('reset-pass');
     $this->assertNull($ret);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:27,代码来源:AbstractPasswordPrimaryAuthenticationProviderTest.php

示例4: run

 /**
  * @throws RuntimeException
  * @return boolean
  */
 public function run()
 {
     $this->unregisterUploadsource();
     $start = microtime(true);
     $config = null;
     $source = ImportStreamSource::newFromFile($this->assertThatFileIsReadableOrThrowException($this->file));
     if (!$source->isGood()) {
         throw new RuntimeException('Import returned with error(s) ' . serialize($source->errors));
     }
     // WikiImporter::__construct without a Config instance was deprecated in MediaWiki 1.25.
     if (class_exists('\\ConfigFactory')) {
         $config = \ConfigFactory::getDefaultInstance()->makeConfig('main');
     }
     $importer = new WikiImporter($source->value, $config);
     $importer->setDebug($this->verbose);
     $reporter = new ImportReporter($importer, false, '', false);
     $reporter->setContext($this->acquireRequestContext());
     $reporter->open();
     $this->exception = false;
     try {
         $importer->doImport();
     } catch (\Exception $e) {
         $this->exception = $e;
     }
     $this->result = $reporter->close();
     $this->importTime = microtime(true) - $start;
     return $this->result->isGood() && !$this->exception;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:32,代码来源:XmlImportRunner.php

示例5: singleton

 /**
  * @return StatCounter
  */
 public static function singleton()
 {
     static $instance = null;
     if (!$instance) {
         $instance = new self(ConfigFactory::getDefaultInstance()->makeConfig('main'));
     }
     return $instance;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:11,代码来源:StatCounter.php

示例6: getConfig

 /**
  * Get the Config object
  *
  * @return Config
  */
 public function getConfig()
 {
     if ($this->config === null) {
         // @todo In the future, we could move this to WebStart.php so
         // the Config object is ready for when initialization happens
         $this->config = ConfigFactory::getDefaultInstance()->makeConfig('main');
     }
     return $this->config;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:14,代码来源:RequestContext.php

示例7: __construct

 /**
  * @param Config $config
  */
 function __construct(Config $config = null)
 {
     $this->data = [];
     $this->translator = new MediaWikiI18N();
     if ($config === null) {
         wfDebug(__METHOD__ . ' was called with no Config instance passed to it');
         $config = ConfigFactory::getDefaultInstance()->makeConfig('main');
     }
     $this->config = $config;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:13,代码来源:QuickTemplate.php

示例8: getProvider

 /**
  * Get an instance of the provider
  * @return LegacyHookPreAuthenticationProvider
  */
 protected function getProvider()
 {
     $request = $this->getMock('FauxRequest', ['getIP']);
     $request->expects($this->any())->method('getIP')->will($this->returnValue('127.0.0.42'));
     $manager = new AuthManager($request, \ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $provider = new LegacyHookPreAuthenticationProvider();
     $provider->setManager($manager);
     $provider->setLogger(new \Psr\Log\NullLogger());
     $provider->setConfig(new \HashConfig(['PasswordAttemptThrottle' => ['count' => 23, 'seconds' => 42]]));
     return $provider;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:15,代码来源:LegacyHookPreAuthenticationProviderTest.php

示例9: __construct

 function __construct($title, Config $config = null)
 {
     if (is_null($title)) {
         throw new MWException(__METHOD__ . ' given a null title.');
     }
     $this->title = $title;
     if ($config === null) {
         wfDebug(__METHOD__ . ' did not have a Config object passed to it');
         $config = ConfigFactory::getDefaultInstance()->makeConfig('main');
     }
     $this->config = $config;
 }
开发者ID:raymondzhangl,项目名称:mediawiki,代码行数:12,代码来源:SpecialUndelete.php

示例10: testGetDefaultInstance

 /**
  * @covers ConfigFactory::getDefaultInstance
  */
 public function testGetDefaultInstance()
 {
     // Set $wgConfigRegistry, and check the default
     // instance read from it
     $this->setMwGlobals('wgConfigRegistry', array('conf1' => 'GlobalVarConfig::newInstance', 'conf2' => 'GlobalVarConfig::newInstance'));
     ConfigFactory::destroyDefaultInstance();
     $factory = ConfigFactory::getDefaultInstance();
     $this->assertInstanceOf('Config', $factory->makeConfig('conf1'));
     $this->assertInstanceOf('Config', $factory->makeConfig('conf2'));
     $this->setExpectedException('ConfigException');
     $factory->makeConfig('conf3');
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:15,代码来源:ConfigFactoryTest.php

示例11: getFieldInfo

 public function getFieldInfo()
 {
     $config = \ConfigFactory::getDefaultInstance()->makeConfig('main');
     $ret = ['email' => ['type' => 'string', 'label' => wfMessage('authmanager-email-label'), 'help' => wfMessage('authmanager-email-help'), 'optional' => true], 'realname' => ['type' => 'string', 'label' => wfMessage('authmanager-realname-label'), 'help' => wfMessage('authmanager-realname-help'), 'optional' => true]];
     if (!$config->get('EnableEmail')) {
         unset($ret['email']);
     }
     if (in_array('realname', $config->get('HiddenPrefs'), true)) {
         unset($ret['realname']);
     }
     return $ret;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:UserDataAuthenticationRequest.php

示例12: __construct

 /**
  * @param string|null $text
  * @param Config|null $config
  */
 function __construct($text = null, Config $config = null)
 {
     $this->mCacheDuration = null;
     $this->mVary = null;
     $this->mConfig = $config ?: ConfigFactory::getDefaultInstance()->makeConfig('main');
     $this->mDisabled = false;
     $this->mText = '';
     $this->mResponseCode = 200;
     $this->mLastModified = false;
     $this->mContentType = 'application/x-wiki';
     if ($text) {
         $this->addText($text);
     }
 }
开发者ID:foxlog,项目名称:wiki,代码行数:18,代码来源:AjaxResponse.php

示例13: getTemplate

 /**
  * Returns a given template function if found, otherwise throws an exception.
  * @param string $templateName The name of the template (without file suffix)
  * @return callable
  * @throws RuntimeException
  */
 protected function getTemplate($templateName)
 {
     // If a renderer has already been defined for this template, reuse it
     if (isset($this->renderers[$templateName]) && is_callable($this->renderers[$templateName])) {
         return $this->renderers[$templateName];
     }
     $filename = $this->getTemplateFilename($templateName);
     if (!file_exists($filename)) {
         throw new RuntimeException("Could not locate template: {$filename}");
     }
     // Read the template file
     $fileContents = file_get_contents($filename);
     // Generate a quick hash for cache invalidation
     $fastHash = md5($fileContents);
     // Fetch a secret key for building a keyed hash of the PHP code
     $config = ConfigFactory::getDefaultInstance()->makeConfig('main');
     $secretKey = $config->get('SecretKey');
     if ($secretKey) {
         // See if the compiled PHP code is stored in cache.
         // CACHE_ACCEL throws an exception if no suitable object cache is present, so fall
         // back to CACHE_ANYTHING.
         $cache = ObjectCache::newAccelerator(array(), CACHE_ANYTHING);
         $key = wfMemcKey('template', $templateName, $fastHash);
         $code = $this->forceRecompile ? null : $cache->get($key);
         if (!$code) {
             $code = $this->compileForEval($fileContents, $filename);
             // Prefix the cached code with a keyed hash (64 hex chars) as an integrity check
             $cache->set($key, hash_hmac('sha256', $code, $secretKey) . $code);
         } else {
             // Verify the integrity of the cached PHP code
             $keyedHash = substr($code, 0, 64);
             $code = substr($code, 64);
             if ($keyedHash !== hash_hmac('sha256', $code, $secretKey)) {
                 // Generate a notice if integrity check fails
                 trigger_error("Template failed integrity check: {$filename}");
             }
         }
         // If there is no secret key available, don't use cache
     } else {
         $code = $this->compileForEval($fileContents, $filename);
     }
     $renderer = eval($code);
     if (!is_callable($renderer)) {
         throw new RuntimeException("Requested template, {$templateName}, is not callable");
     }
     $this->renderers[$templateName] = $renderer;
     return $renderer;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:54,代码来源:TemplateParser.php

示例14: doImport

 private function doImport($importStreamSource)
 {
     $importer = new WikiImporter($importStreamSource->value, ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $importer->setDebug(true);
     $reporter = new ImportReporter($importer, false, '', false);
     $reporter->setContext(new RequestContext());
     $reporter->open();
     $exception = false;
     try {
         $importer->doImport();
     } catch (Exception $e) {
         $exception = $e;
     }
     $result = $reporter->close();
     $this->assertFalse($exception);
     $this->assertTrue($result->isGood());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:17,代码来源:ImportLinkCacheIntegrationTest.php

示例15: newRandom

 /**
  * Return an instance with a new, random password
  * @return TemporaryPasswordAuthenticationRequest
  */
 public static function newRandom()
 {
     $config = \ConfigFactory::getDefaultInstance()->makeConfig('main');
     // get the min password length
     $minLength = $config->get('MinimalPasswordLength');
     $policy = $config->get('PasswordPolicy');
     foreach ($policy['policies'] as $p) {
         if (isset($p['MinimalPasswordLength'])) {
             $minLength = max($minLength, $p['MinimalPasswordLength']);
         }
         if (isset($p['MinimalPasswordLengthToLogin'])) {
             $minLength = max($minLength, $p['MinimalPasswordLengthToLogin']);
         }
     }
     $password = \PasswordFactory::generateRandomPasswordString($minLength);
     return new self($password);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:21,代码来源:TemporaryPasswordAuthenticationRequest.php


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