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


PHP StoreFactory::getStore方法代码示例

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


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

示例1: 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);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:36,代码来源:SharedDependencyContainer.php

示例2: getTypeProperties

 protected function getTypeProperties($typeLabel)
 {
     global $wgRequest, $smwgTypePagingLimit;
     if ($smwgTypePagingLimit <= 0) {
         return '';
         // not too useful, but we comply to this request
     }
     $from = $wgRequest->getVal('from');
     $until = $wgRequest->getVal('until');
     $typeValue = DataValueFactory::getInstance()->newTypeIDValue('__typ', $typeLabel);
     if (!$typeValue->isValid()) {
         return $this->msg('smw-special-types-no-such-type')->escaped();
     }
     $store = \SMW\StoreFactory::getStore();
     $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until);
     $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options);
     if (!$options->ascending) {
         $diWikiPages = array_reverse($diWikiPages);
     }
     $result = '';
     if (count($diWikiPages) > 0) {
         $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until);
         $title = $this->getTitleFor('Types', $typeLabel);
         $title->setFragment('#SMWResults');
         // Make navigation point to the result list.
         $navigation = $pageLister->getNavigationLinks($title);
         $resultNumber = min($smwgTypePagingLimit, count($diWikiPages));
         $typeName = $typeValue->getLongWikiText();
         $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMessage('smw_type_header', $typeName)->text() . "</h2>\n<p>" . wfMessage('smw_typearticlecount')->numParams($resultNumber)->text() . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>";
     }
     return $result;
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:32,代码来源:SMW_SpecialTypes.php

示例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);
     /**
      * @since  1.9
      *
      * @return Cache
      */
     $this->registerObject('Cache', function (DependencyBuilder $builder) {
         return ApplicationFactory::getInstance()->newCacheFactory()->newMediaWikiCompositeCache();
     }, DependencyObject::SCOPE_SINGLETON);
 }
开发者ID:ReachingOut,项目名称:SemanticMediaWiki,代码行数:34,代码来源:SharedDependencyContainer.php

示例4: getHtml

 /**
  * Returns the HTML which is added to $wgOut after the article text.
  *
  * @return string
  */
 protected function getHtml()
 {
     if ($this->limit > 0) {
         // limit==0: configuration setting to disable this completely
         $store = StoreFactory::getStore();
         $concept = $store->getConceptCacheStatus($this->getDataItem());
         $description = new ConceptDescription($this->getDataItem());
         $query = SMWPageLister::getQuery($description, $this->limit, $this->from, $this->until);
         $queryResult = $store->getQueryResult($query);
         $diWikiPages = $queryResult->getResults();
         if ($this->until !== '') {
             $diWikiPages = array_reverse($diWikiPages);
         }
         $errors = $queryResult->getErrors();
     } else {
         $diWikiPages = array();
         $errors = array();
     }
     $pageLister = new SMWPageLister($diWikiPages, null, $this->limit, $this->from, $this->until);
     $this->mTitle->setFragment('#SMWResults');
     // Make navigation point to the result list.
     $navigation = $pageLister->getNavigationLinks($this->mTitle);
     $titleText = htmlspecialchars($this->mTitle->getText());
     $resultNumber = min($this->limit, count($diWikiPages));
     // Concept cache information
     if ($concept instanceof DIConcept && $concept->getCacheStatus() === 'full') {
         $cacheInformation = Html::element('span', array('class' => 'smw-concept-cache-information'), ' ' . $this->getContext()->msg('smw-concept-cache-text', $this->getContext()->getLanguage()->formatNum($concept->getCacheCount()), $this->getContext()->getLanguage()->date($concept->getCacheDate()), $this->getContext()->getLanguage()->time($concept->getCacheDate()))->text());
     } else {
         $cacheInformation = '';
     }
     return Html::element('br', array('id' => 'smwfootbr')) . Html::element('a', array('name' => 'SMWResults'), null) . Html::rawElement('div', array('id' => 'mw-pages'), Html::rawElement('h2', array(), $this->getContext()->msg('smw_concept_header', $titleText)->text()) . Html::element('span', array(), $this->getContext()->msg('smw_conceptarticlecount', $resultNumber)->parse()) . smwfEncodeMessages($errors) . ' ' . $navigation . $cacheInformation . $pageLister->formatList());
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:37,代码来源:ConceptPage.php

示例5: testGetters

 public function testGetters()
 {
     $diType = SMWDataItem::TYPE_NUMBER;
     $name = 'smw_di_number';
     $instance = new TableDefinition($diType, $name);
     $this->assertInternalType('array', $instance->getFields(StoreFactory::getStore('SMWSQLStore3')));
     $this->assertEquals($diType, $instance->getDiType());
     $this->assertEquals($name, $instance->getName());
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:9,代码来源:TableDefinitionTest.php

示例6: getSMWStore

 /**
  * Helper function to get the SMW data store for different versions
  * of SMW.
  */
 public static function getSMWStore()
 {
     if (class_exists('\\SMW\\StoreFactory')) {
         // SMW 1.9+
         return \SMW\StoreFactory::getStore();
     } else {
         return smwfGetStore();
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:13,代码来源:SD_Utils.php

示例7: testGetters

 /**
  * @test TableDefinition::getFields
  * @test TableDefinition::getDiType
  * @test TableDefinition::getName
  *
  * @since 1.9
  */
 public function testGetters()
 {
     $diType = SMWDataItem::TYPE_NUMBER;
     $name = 'smw_di_number';
     $instance = $this->newInstance($diType, $name);
     $this->assertInternalType('array', $instance->getFields(StoreFactory::getStore('SMWSQLStore3')), 'Asserts that getFields() returns an array');
     $this->assertEquals($diType, $instance->getDiType(), 'Asserts that getDiType() returns the corret object');
     $this->assertEquals($name, $instance->getName(), 'Asserts that getName() returns the corret object');
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:16,代码来源:TableDefinitionTest.php

示例8: testCacheNoCacheOnSQLStore

 /**
  * @dataProvider getCacheNonCacheDataProvider
  */
 public function testCacheNoCacheOnSQLStore(array $test, array $expected, array $info)
 {
     $store = StoreFactory::getStore('SMWSQLStore3');
     // Sample A
     $instance = $this->newInstance($store, $test['A']['property'], $test['A']['count'], $test['cacheEnabled']);
     $this->assertEquals($expected['A'], $instance->getResults(), $info['msg']);
     // Sample B
     $instance = $this->newInstance($store, $test['B']['property'], $test['B']['count'], $test['cacheEnabled']);
     $this->assertEquals($expected['B'], $instance->getResults(), $info['msg']);
     $this->assertEquals($test['cacheEnabled'], $instance->isCached());
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:14,代码来源:WantedPropertiesCollectorTest.php

示例9: setUp

 protected function setUp()
 {
     $this->store = StoreFactory::getStore();
     if (!$this->store instanceof SPARQLStore) {
         $this->markTestSkipped("Requires a SPARQLStore instance");
     }
     $this->sparqlDatabase = $this->store->getConnection();
     if (!$this->sparqlDatabase->setConnectionTimeoutInSeconds(5)->ping()) {
         $this->markTestSkipped("Can't connect to the SparlDatabase");
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:11,代码来源:RedirectLookupIntegrationTest.php

示例10: setupStore

 protected function setupStore($source, $expectedToRun = 0)
 {
     $storeId = isset($GLOBALS['smwgQuerySources'][$source]) ? $GLOBALS['smwgQuerySources'][$source] : null;
     $queryResult = $this->getMockBuilder('SMWQueryResult')->disableOriginalConstructor()->getMock();
     $queryResult->expects($this->exactly($expectedToRun))->method('getCount')->will($this->returnValue(0));
     $queryResult->expects($this->any())->method('getErrors')->will($this->returnValue(array()));
     $store = StoreFactory::getStore($storeId);
     if (method_exists($store, 'setQueryResult')) {
         $store->setQueryResult($queryResult);
     }
     return $store;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:12,代码来源:QuerySourceIntegrationTest.php

示例11: testProcessOnSQLStore

 public function testProcessOnSQLStore()
 {
     $userLanguage = $this->getMockBuilder('\\Language')->disableOriginalConstructor()->getMock();
     ApplicationFactory::getInstance()->registerObject('Store', StoreFactory::getStore());
     $extraStats = array();
     $version = '1.21';
     $instance = new SpecialStatsAddExtra($extraStats, $version, $userLanguage);
     $this->assertTrue($instance->process());
     // This is a "cheap" check against the SQLStore as it could return any
     // value therefore we use a message key as only known constant to verify
     // that the matching process was successful
     $this->assertTrue($this->matchArray($extraStats, 'smw-statistics-property-instance'));
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:13,代码来源:SpecialStatsAddExtraTest.php

示例12: 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();
     });
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:49,代码来源:SharedCallbackContainer.php

示例13: setUp

 protected function setUp()
 {
     $this->store = StoreFactory::getStore();
     if (!$this->store instanceof SPARQLStore) {
         $this->markTestSkipped("Requires a SPARQLStore instance");
     }
     $sparqlDatabase = $this->store->getConnection();
     if (!$sparqlDatabase->setConnectionTimeoutInSeconds(5)->ping()) {
         $this->markTestSkipped("Can't connect to the SPARQL database");
     }
     $sparqlDatabase->deleteAll();
     $this->queryResultValidator = new QueryResultValidator();
     $this->semanticDataFactory = new SemanticDataFactory();
     $this->dataValueFactory = DataValueFactory::getInstance();
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:15,代码来源:QueryResultLookupWithoutBaseStoreIntegrationTest.php

示例14: execute

 /**
  * @see Maintenance::execute
  */
 public function execute()
 {
     if (!defined('SMW_VERSION')) {
         $this->output("You need to have SMW enabled in order to use this maintenance script!\n\n");
         exit;
     }
     $store = StoreFactory::getStore();
     $statsTable = new PropertyStatisticsTable($store->getConnection('mw.db'), \SMWSQLStore3::PROPERTY_STATISTICS_TABLE);
     // Need to instantiate an extra object here since we cannot make this class itself
     // into a MessageReporter since the maintenance script does not load the interface in time.
     $reporter = new ObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $statisticsRebuilder = new SimplePropertyStatisticsRebuilder($store, $reporter);
     $statisticsRebuilder->rebuild($statsTable);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:18,代码来源:rebuildPropertyStatistics.php

示例15: getTypeProperties

 protected function getTypeProperties($typeLabel)
 {
     global $wgRequest, $smwgTypePagingLimit;
     if ($smwgTypePagingLimit <= 0) {
         return '';
         // not too useful, but we comply to this request
     }
     $from = $wgRequest->getVal('from');
     $until = $wgRequest->getVal('until');
     $typeValue = DataValueFactory::getInstance()->newTypeIDValue('__typ', $typeLabel);
     $this->getOutput()->prependHTML($this->getTypesLink());
     if (!$typeValue->isValid()) {
         return $this->msg('smw-special-types-no-such-type')->escaped();
     }
     $store = \SMW\StoreFactory::getStore();
     $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until);
     $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options);
     if (!$options->ascending) {
         $diWikiPages = array_reverse($diWikiPages);
     }
     $escapedTypeLabel = htmlspecialchars($typeValue->getWikiValue());
     $canonicalLabel = DataTypeRegistry::getInstance()->findCanonicalLabelById($typeValue->getDataItem()->getFragment());
     $typeKey = 'smw-sp-types' . strtolower($typeValue->getDataItem()->getFragment());
     $messageKey = wfMessage($typeKey)->exists() ? $typeKey : 'smw-sp-types-default';
     $result = \Html::rawElement('div', array('class' => 'smw-sp-types-intro' . $typeKey), wfMessage($messageKey, str_replace('_', ' ', $escapedTypeLabel))->parse() . ' ' . wfMessage('smw-sp-types-help', str_replace(' ', '_', $canonicalLabel))->parse());
     $result .= $this->displayExtraInformationAbout($typeValue);
     if (count($diWikiPages) > 0) {
         $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until);
         $title = $this->getTitleFor('Types', $typeLabel);
         $title->setFragment('#SMWResults');
         // Make navigation point to the result list.
         $navigation = $pageLister->getNavigationLinks($title);
         $resultNumber = min($smwgTypePagingLimit, count($diWikiPages));
         $typeName = $typeValue->getLongWikiText();
         $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMessage('smw_type_header', $typeName)->text() . "</h2>\n<p>" . wfMessage('smw_typearticlecount')->numParams($resultNumber)->text() . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>";
     }
     return $result;
 }
开发者ID:FlorianSW,项目名称:SemanticMediaWiki,代码行数:38,代码来源:SMW_SpecialTypes.php


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