本文整理汇总了PHP中ConfigFactory类的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFactory类的具体用法?PHP ConfigFactory怎么用?PHP ConfigFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param ConfigFactory $configFactory
* @param ResolverInterface $localeResolver
* @param CurrentCustomer $currentCustomer
* @param PayfastHelper $paymentHelper
* @param PaymentHelper $paymentHelper
*/
public function __construct(\Psr\Log\LoggerInterface $logger, ConfigFactory $configFactory, ResolverInterface $localeResolver, CurrentCustomer $currentCustomer, PayfastHelper $payfastHelper, PaymentHelper $paymentHelper)
{
$this->_logger = $logger;
$pre = __METHOD__ . ' : ';
$this->_logger->debug($pre . 'bof');
$this->localeResolver = $localeResolver;
$this->config = $configFactory->create();
$this->currentCustomer = $currentCustomer;
$this->payfastHelper = $payfastHelper;
$this->paymentHelper = $paymentHelper;
foreach ($this->methodCodes as $code) {
$this->methods[$code] = $this->paymentHelper->getMethodInstance($code);
}
$this->_logger->debug($pre . 'eof and this methods has : ', $this->methods);
}
开发者ID:PayFast,项目名称:mod-magento_2,代码行数:22,代码来源:PayfastConfigProvider.php
示例2: 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
示例3: 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
示例4: 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
示例5: __construct
public function __construct()
{
$this->config = ConfigFactory::getConfig();
$this->db = DblFactory::getConn();
$this->toShow = $this->config->get('xmlPostsToShow') - 1;
$this->numPosts = $this->db->numRows($this->db->query('select * from ' . $this->config->get('prefix') . '_news'));
}
开发者ID:rgantt,项目名称:websheets,代码行数:7,代码来源:RSS.php
示例6: __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
示例7: mvcRun
/**
* 运行mvc
*/
static function mvcRun()
{
/* mvc入口 */
$config = ConfigFactory::get('controller');
foreach (array('module' => 'm', 'controller' => 'c', 'action' => 'a') as $k => $v) {
${$k} = trim($_GET[$v]);
if (empty(${$k})) {
${$k} = $config['default' . ucfirst($k)];
}
}
$classController = ucfirst($controller) . 'Controller';
$path = "{$module}/controllers/{$classController}";
if (preg_match("/^([a-z\\d\\_\\-]+\\/){2}[a-z\\d\\_\\-]+\$/i", $path) && file_exists(WEB_SYSTEM . "/modules/{$path}.php")) {
require WEB_SYSTEM . "/modules/{$path}.php";
$instance = new $classController();
$instance->module = $module;
$instance->controller = $controller;
$instance->action = $action;
$methodAction = 'action' . $action;
if (method_exists($instance, $methodAction)) {
call_user_func(array($instance, 'beforeAction'));
call_user_func(array($instance, $methodAction));
call_user_func(array($instance, 'afterAction'));
return true;
}
}
die('Invalid params (path:' . htmlspecialchars($path) . ')');
return false;
}
开发者ID:sdgdsffdsfff,项目名称:shfy-giftbag,代码行数:32,代码来源:Application.class.php
示例8: 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
示例9: 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
示例10: __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
示例11: 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
示例12: 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
示例13: 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
示例14: __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
示例15: open
/**
* 获取redis client实例
* @param string $key
* @return IRedis
*/
static function open($key = 'default')
{
$instance =& self::$INSTANCES[$key];
if (isset($instance) == false) {
$config = ConfigFactory::get('redis', $key);
if (empty($config)) {
die("Undefined Redis Config \"{$key}\"");
}
$instance = new RedisClient();
$instance->setServers($config['servers']);
}
return $instance;
}
开发者ID:sdgdsffdsfff,项目名称:shfy-giftbag,代码行数:18,代码来源:RedisFactory.class.php
示例16: open
/**
* 获取单例的数据库实例
* @param string $key
* @return IDatabase
*/
static function open($key = 'default')
{
$instance =& self::$INSTANCES[$key];
if (isset($instance) == false) {
$config = ConfigFactory::get('db', $key);
if (empty($config)) {
die("Undefined Database Config \"{$key}\"");
}
$className = 'Database' . ucfirst($config['type']);
$instance = new $className();
$instance->connect($config['host'], $config['port'], $config['database'], $config['user'], $config['password'], $config['charset']);
}
return $instance;
}
开发者ID:sdgdsffdsfff,项目名称:shfy-giftbag,代码行数:19,代码来源:DatabaseFactory.class.php
示例17: __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
示例18: 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
示例19: 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
示例20: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论