本文整理汇总了PHP中SMW\Settings::newFromGlobals方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::newFromGlobals方法的具体用法?PHP Settings::newFromGlobals怎么用?PHP Settings::newFromGlobals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\Settings
的用法示例。
在下文中一共展示了Settings::newFromGlobals方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerSettings
private function registerSettings()
{
$this->applicationFactory->registerObject('Settings', Settings::newFromGlobals($this->globalVars));
if (CompatibilityMode::extensionNotEnabled()) {
CompatibilityMode::disableSemantics();
}
}
示例2: getInstance
/**
* Returns a static instance with an invoked global settings array
*
* @par Example:
* @code
* \SMW\NamespaceExaminer::getInstance()->isSemanticEnabled( NS_MAIN )
* @endcode
*
* @note Used in smwfIsSemanticsProcessed
*
* @since 1.9
*
* @return NamespaceExaminer
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = self::newFromArray(Settings::newFromGlobals()->get('smwgNamespacesWithSemanticLinks'));
}
return self::$instance;
}
示例3: loadAtInstantiation
/**
* @since 1.9
*/
protected function loadAtInstantiation()
{
/**
* Settings object definition
*
* @since 1.9
*
* @return Settings
*/
$this->registerObject('Settings', function () {
return Settings::newFromGlobals();
}, DependencyObject::SCOPE_SINGLETON);
/**
* Store object definition
*
* @since 1.9
*
* @return Store
*/
$this->registerObject('Store', function (DependencyBuilder $builder) {
return StoreFactory::getStore($builder->newObject('Settings')->get('smwgDefaultStore'));
}, DependencyObject::SCOPE_SINGLETON);
/**
* CacheHandler object definition
*
* @since 1.9
*
* @return CacheHandler
*/
$this->registerObject('CacheHandler', function (DependencyBuilder $builder) {
return CacheHandler::newFromId($builder->newObject('Settings')->get('smwgCacheType'));
}, DependencyObject::SCOPE_SINGLETON);
}
示例4: loadAtInstantiation
/**
* @since 1.9
*/
protected function loadAtInstantiation()
{
/**
* Settings object definition
*
* @since 1.9
*
* @return Settings
*/
$this->registerObject('Settings', function () {
return Settings::newFromGlobals();
}, DependencyObject::SCOPE_SINGLETON);
/**
* Store object definition
*
* @since 1.9
*
* @return Store
*/
$this->registerObject('Store', function (DependencyBuilder $builder) {
return StoreFactory::getStore($builder->newObject('Settings')->get('smwgDefaultStore'));
}, DependencyObject::SCOPE_SINGLETON);
/**
* @since 1.9
*
* @return Cache
*/
$this->registerObject('Cache', function (DependencyBuilder $builder) {
return ApplicationFactory::getInstance()->newCacheFactory()->newMediaWikiCompositeCache();
}, DependencyObject::SCOPE_SINGLETON);
}
示例5: testGetDefaultStore
public function testGetDefaultStore()
{
$instance = StoreFactory::getStore();
$this->assertInstanceOf(Settings::newFromGlobals()->get('smwgDefaultStore'), $instance);
$this->assertSame(StoreFactory::getStore(), $instance);
StoreFactory::clear();
$this->assertNotSame(StoreFactory::getStore(), $instance);
}
示例6: newFromId
/**
* Factory method that creates a CacheHandler instance and instantiate a
* BagOStuff object from available settings ($smwgCacheType) while
* invoking additional parameters ($wgCachePrefix etc.)
*
* @par Example:
* @code
* $cache = new CacheHandler::newFromId()->setkey( new CachIdGenerator( 'Foo' ) )
*
* $cache->set( 'CacheableObject' )
* $cache->get() returns 'CacheableObject'
* $cache->delete() deletes 'CacheableObject'
* @endcode
*
* @note If a BagOStuff instance is not available setCacheEnabled() is
* disabled by default which prevents to run into unintended behaviour
* while trying to access BagOStuff methods.
*
* @note This method is exposed to $wgObjectCaches, $wgCachePrefix globals
* which can't and shouldn't be accessed otherwise. It is the task of this
* method alone to invoke globals and avoid leakage into the object
* life cycle.
*
* @note This method serves invoked instances from a static variable due to
* the fact that the actual working object is being accessed through
* getCache() and therefore not in direct conflict with its testability.
*
* @since 1.9
*
* @param string $id Ids available in wgObjectCaches
*
* @return CacheHandler
*/
public static function newFromId($id = false)
{
$cacheType = $id ? $id : Settings::newFromGlobals()->get('smwgCacheType');
if (!isset(self::$instance[$cacheType])) {
if ($cacheType && array_key_exists($cacheType, $GLOBALS['wgObjectCaches'])) {
$cache = new self(ObjectCache::getInstance($cacheType));
} else {
$cache = new self();
}
$cache->setCacheEnabled(true);
self::$instance[$cacheType] = $cache;
}
return self::$instance[$cacheType];
}
示例7: registerCallbackHandlers
private function registerCallbackHandlers($callbackLoader)
{
$callbackLoader->registerExpectedReturnType('Settings', '\\SMW\\Settings');
$callbackLoader->registerCallback('Settings', function () use($callbackLoader) {
return Settings::newFromGlobals();
});
$callbackLoader->registerExpectedReturnType('Store', '\\SMW\\Store');
$callbackLoader->registerCallback('Store', function () use($callbackLoader) {
return StoreFactory::getStore($callbackLoader->singleton('Settings')->get('smwgDefaultStore'));
});
$callbackLoader->registerExpectedReturnType('Cache', '\\Onoi\\Cache\\Cache');
$callbackLoader->registerCallback('Cache', function () {
return ApplicationFactory::getInstance()->newCacheFactory()->newMediaWikiCompositeCache();
});
$callbackLoader->registerCallback('NamespaceExaminer', function () use($callbackLoader) {
return NamespaceExaminer::newFromArray($callbackLoader->singleton('Settings')->get('smwgNamespacesWithSemanticLinks'));
});
$callbackLoader->registerExpectedReturnType('ParserData', '\\SMW\\ParserData');
$callbackLoader->registerCallback('ParserData', function (\Title $title, \ParserOutput $parserOutput) {
return new ParserData($title, $parserOutput);
});
$callbackLoader->registerCallback('MessageFormatter', function (\Language $language) {
return new MessageFormatter($language);
});
$callbackLoader->registerExpectedReturnType('PageCreator', '\\SMW\\MediaWiki\\PageCreator');
$callbackLoader->registerCallback('PageCreator', function () {
return new PageCreator();
});
$callbackLoader->registerExpectedReturnType('TitleCreator', '\\SMW\\MediaWiki\\TitleCreator');
$callbackLoader->registerCallback('TitleCreator', function () {
return new TitleCreator();
});
$callbackLoader->registerExpectedReturnType('WikiPage', '\\WikiPage');
$callbackLoader->registerCallback('WikiPage', function (\Title $title) {
return \WikiPage::factory($title);
});
$callbackLoader->registerExpectedReturnType('ContentParser', '\\SMW\\ContentParser');
$callbackLoader->registerCallback('ContentParser', function (\Title $title) {
return new ContentParser($title);
});
$callbackLoader->registerExpectedReturnType('JobFactory', '\\SMW\\MediaWiki\\Jobs\\JobFactory');
$callbackLoader->registerCallback('JobFactory', function () {
return new JobFactory();
});
$callbackLoader->registerExpectedReturnType('FactboxFactory', '\\SMW\\Factbox\\FactboxFactory');
$callbackLoader->registerCallback('FactboxFactory', function () {
return new FactboxFactory();
});
}
示例8: testCanonicalNames
public function testCanonicalNames()
{
$this->mwHooksHandler->deregisterListedHooks();
$count = 0;
$index = NamespaceManager::buildNamespaceIndex(Settings::newFromGlobals()->get('smwgNamespaceIndex'));
$names = NamespaceManager::getCanonicalNames();
$this->assertInternalType('array', $names);
$this->assertInternalType('array', $index);
foreach ($index as $ns => $idx) {
$mwNamespace = MWNamespace::getCanonicalName($idx);
if ($mwNamespace && isset($names[$idx])) {
$this->assertEquals($mwNamespace, $names[$idx]);
$count++;
}
}
$this->assertCount($count, $names, "Asserts that expected amount of cannonical names have been verified");
}
示例9: testNewFromGlobals
/**
* @dataProvider globalsSettingsProvider
*
* @since 1.9
*/
public function testNewFromGlobals(array $settings)
{
$instance = Settings::newFromGlobals();
$this->assertInstanceOf($this->getClass(), $instance);
// Assert that newFromGlobals is a static instance
$this->assertTrue($instance === Settings::newFromGlobals());
// Reset instance
$instance->clear();
$this->assertTrue($instance !== Settings::newFromGlobals());
foreach ($settings as $key => $value) {
$this->assertTrue($instance->has($key), "Failed asserting that {$key} exists");
}
}
示例10: getConfiguration
private static function getConfiguration()
{
return Settings::newFromGlobals();
}
示例11: registerCallbackHandlers
private function registerCallbackHandlers($callbackLoader)
{
$callbackLoader->registerExpectedReturnType('Settings', '\\SMW\\Settings');
$callbackLoader->registerCallback('Settings', function () use($callbackLoader) {
return Settings::newFromGlobals();
});
$callbackLoader->registerExpectedReturnType('Store', '\\SMW\\Store');
$callbackLoader->registerCallback('Store', function ($store = null) use($callbackLoader) {
return StoreFactory::getStore($store !== null ? $store : $callbackLoader->singleton('Settings')->get('smwgDefaultStore'));
});
$callbackLoader->registerExpectedReturnType('Cache', '\\Onoi\\Cache\\Cache');
$callbackLoader->registerCallback('Cache', function ($cacheType = null) use($callbackLoader) {
return $callbackLoader->load('CacheFactory')->newMediaWikiCompositeCache($cacheType);
});
$callbackLoader->registerCallback('NamespaceExaminer', function () use($callbackLoader) {
return NamespaceExaminer::newFromArray($callbackLoader->singleton('Settings')->get('smwgNamespacesWithSemanticLinks'));
});
$callbackLoader->registerExpectedReturnType('ParserData', '\\SMW\\ParserData');
$callbackLoader->registerCallback('ParserData', function (\Title $title, \ParserOutput $parserOutput) {
return new ParserData($title, $parserOutput);
});
$callbackLoader->registerCallback('MessageFormatter', function (\Language $language) {
return new MessageFormatter($language);
});
$callbackLoader->registerCallback('MediaWikiNsContentReader', function () use($callbackLoader) {
$callbackLoader->registerExpectedReturnType('MediaWikiNsContentReader', '\\SMW\\MediaWiki\\MediaWikiNsContentReader');
return new MediaWikiNsContentReader();
});
$callbackLoader->registerExpectedReturnType('PageCreator', '\\SMW\\MediaWiki\\PageCreator');
$callbackLoader->registerCallback('PageCreator', function () {
return new PageCreator();
});
$callbackLoader->registerCallback('JobQueueLookup', function (Database $connection) use($callbackLoader) {
$callbackLoader->registerExpectedReturnType('JobQueueLookup', '\\SMW\\MediaWiki\\JobQueueLookup');
return new JobQueueLookup($connection);
});
$callbackLoader->registerCallback('ManualEntryLogger', function () use($callbackLoader) {
$callbackLoader->registerExpectedReturnType('ManualEntryLogger', '\\SMW\\MediaWiki\\ManualEntryLogger');
return new ManualEntryLogger();
});
$callbackLoader->registerExpectedReturnType('TitleCreator', '\\SMW\\MediaWiki\\TitleCreator');
$callbackLoader->registerCallback('TitleCreator', function () {
return new TitleCreator();
});
$callbackLoader->registerExpectedReturnType('ContentParser', '\\SMW\\ContentParser');
$callbackLoader->registerCallback('ContentParser', function (\Title $title) {
return new ContentParser($title);
});
$callbackLoader->registerExpectedReturnType('DeferredCallableUpdate', '\\SMW\\DeferredCallableUpdate');
$callbackLoader->registerCallback('DeferredCallableUpdate', function (\Closure $callback) {
return new DeferredCallableUpdate($callback);
});
/**
* @var InMemoryPoolCache
*/
$callbackLoader->registerCallback('InMemoryPoolCache', function () use($callbackLoader) {
$callbackLoader->registerExpectedReturnType('InMemoryPoolCache', '\\SMW\\InMemoryPoolCache');
return InMemoryPoolCache::getInstance();
});
/**
* @var PropertyAnnotatorFactory
*/
$callbackLoader->registerCallback('PropertyAnnotatorFactory', function () use($callbackLoader) {
$callbackLoader->registerExpectedReturnType('PropertyAnnotatorFactory', '\\SMW\\PropertyAnnotatorFactory');
return new PropertyAnnotatorFactory();
});
}
示例12: registerSettings
private function registerSettings()
{
$this->applicationFactory->registerObject('Settings', Settings::newFromGlobals($this->globalVars));
}
示例13: doListConfigurationSettings
protected function doListConfigurationSettings()
{
$this->printRawOutput(function ($instance) {
print '<pre>' . $instance->encodeJson(Settings::newFromGlobals()->toArray()) . '</pre>';
});
}
示例14: getStatistics
public function getStatistics()
{
$statisticsCollector = new StatisticsCollector($this, wfGetDB(DB_SLAVE), Settings::newFromGlobals());
return $statisticsCollector->getResults();
}