本文整理汇总了PHP中SMW\SemanticData::addPropertyObjectValue方法的典型用法代码示例。如果您正苦于以下问题:PHP SemanticData::addPropertyObjectValue方法的具体用法?PHP SemanticData::addPropertyObjectValue怎么用?PHP SemanticData::addPropertyObjectValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\SemanticData
的用法示例。
在下文中一共展示了SemanticData::addPropertyObjectValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAnnotation
/**
* @since 1.0
*
* @return boolean
*/
public function addAnnotation()
{
if (!$this->hasShortUrlUtils()) {
throw new RuntimeException('Expected class ShortUrlUtils to be available');
}
$shortURL = $this->getShortUrl($this->semanticData->getSubject()->getTitle());
if ($shortURL !== null) {
$this->semanticData->addPropertyObjectValue(new DIProperty(PropertyRegistry::getInstance()->getPropertyId('_SHORTURL')), new DIUri('http', $shortURL, '', ''));
}
return true;
}
示例2: getSemanticData
/**
* @since 2.0
*
* @return SemanticData
*/
public function getSemanticData(DIWikiPage $subject)
{
$requestOptions = new RequestOptions();
$requestOptions->sort = true;
$semanticData = new SemanticData($subject);
$incomingProperties = $this->store->getInProperties($subject, $requestOptions);
foreach ($incomingProperties as $property) {
$values = $this->store->getPropertySubjects($property, null);
foreach ($values as $value) {
$semanticData->addPropertyObjectValue($property, $value);
}
}
return $semanticData;
}
示例3: fetchIncomingDataFromStore
/**
* @since 1.9.2
*
* @return SemanticData
*/
public function fetchIncomingDataFromStore()
{
$requestOptions = new \SMWRequestOptions();
$requestOptions->sort = true;
$subject = $this->getPageData()->getSubject();
$semanticData = new SemanticData($subject);
$incomingProperties = $this->getStore()->getInProperties($subject, $requestOptions);
foreach ($incomingProperties as $property) {
$values = $this->getStore()->getPropertySubjects($property, null);
foreach ($values as $value) {
$semanticData->addPropertyObjectValue($property, $value);
}
}
return $semanticData;
}
示例4: testDoSparqlDataUpdateOnMockBaseStore
public function testDoSparqlDataUpdateOnMockBaseStore()
{
$semanticData = new SemanticData(new DIWikiPage(__METHOD__, NS_MAIN));
$semanticData->addPropertyObjectValue(new DIProperty('Foo'), $semanticData->getSubject());
$repositoryResult = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\RepositoryResult')->disableOriginalConstructor()->getMock();
$baseStore = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$sparqlDatabase = $this->getMockBuilder('\\SMWSparqlDatabase')->disableOriginalConstructor()->getMock();
$sparqlDatabase->expects($this->atLeastOnce())->method('select')->will($this->returnValue($repositoryResult));
$sparqlDatabase->expects($this->once())->method('insertData');
$connectionManager = $this->getMockBuilder('\\SMW\\ConnectionManager')->disableOriginalConstructor()->getMock();
$connectionManager->expects($this->any())->method('getConnection')->will($this->returnValue($sparqlDatabase));
$instance = new SPARQLStore($baseStore);
$instance->setConnectionManager($connectionManager);
$instance->doSparqlDataUpdate($semanticData);
}
示例5: getSemanticData
/**
* Retrieve a copy of the semantic data for a wiki page, possibly filtering
* it so that only essential properties are included (in some cases, we only
* want to export stub information about a page).
* We make a copy of the object since we may want to add more data later on
* and we do not want to modify the store's result which may be used for
* caching purposes elsewhere.
*/
protected function getSemanticData(SMWDIWikiPage $diWikiPage, $core_props_only)
{
// Issue 619
// Resolve the redirect target and return a container with information
// about the redirect
if ($diWikiPage->getTitle() !== null && $diWikiPage->getTitle()->isRedirect()) {
try {
$redirectTarget = $this->getDeepRedirectTargetResolver()->findRedirectTargetFor($diWikiPage->getTitle());
} catch (\Exception $e) {
$redirectTarget = null;
}
// Couldn't resolve the redirect which is most likely caused by a
// circular redirect therefore we give up
if ($redirectTarget === null) {
return null;
}
$semData = new SemanticData($diWikiPage);
$semData->addPropertyObjectValue(new DIProperty('_REDI'), DIWikiPage::newFromTitle($redirectTarget));
return $semData;
}
$semdata = \SMW\StoreFactory::getStore()->getSemanticData($diWikiPage, $core_props_only ? array('__spu', '__typ', '__imp') : false);
// advise store to retrieve only core things
if ($core_props_only) {
// be sure to filter all non-relevant things that may still be present in the retrieved
$result = new SMWSemanticData($diWikiPage);
foreach (array('_URI', '_TYPE', '_IMPO') as $propid) {
$prop = new SMW\DIProperty($propid);
$values = $semdata->getPropertyValues($prop);
foreach ($values as $dv) {
$result->addPropertyObjectValue($prop, $dv);
}
}
} else {
$result = clone $semdata;
}
return $result;
}
示例6: testClear
public function testClear()
{
$title = Title::newFromText(__METHOD__);
$instance = new SemanticData(DIWikiPage::newFromTitle($title));
$instance->addPropertyObjectValue(new DIProperty('_MDAT'), DITime::newFromTimestamp(1272508903));
$this->assertFalse($instance->isEmpty());
$instance->clear();
$this->assertTrue($instance->isEmpty());
}
示例7: testDeleteFor
public function testDeleteFor()
{
$subject = new DIWikiPage('Foobar', NS_MAIN, '', 'abc');
$semanticData = new SemanticData($subject);
$semanticData->addPropertyObjectValue(new DIProperty('_REDI'), new DIWikiPage('Bar', NS_MAIN));
$store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
$container = $this->getMockBuilder('\\Onoi\\BlobStore\\Container')->disableOriginalConstructor()->getMock();
$container->expects($this->at(0))->method('has')->with($this->stringContains('sd:'))->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->with($this->stringContains('sd:'))->will($this->returnValue($semanticData));
$container->expects($this->at(2))->method('has')->with($this->stringContains('list'))->will($this->returnValue(true));
$container->expects($this->at(3))->method('get')->with($this->stringContains('list'))->will($this->returnValue(array('abc', '123')));
$blobStore = $this->getMockBuilder('\\Onoi\\BlobStore\\BlobStore')->disableOriginalConstructor()->getMock();
$blobStore->expects($this->any())->method('canUse')->will($this->returnValue(true));
$blobStore->expects($this->atLeastOnce())->method('read')->will($this->returnValue($container));
$blobStore->expects($this->exactly(4))->method('delete');
$instance = new CachedValueLookupStore($store, $blobStore);
$instance->setValueLookupFeatures(SMW_VL_SD);
$instance->deleteFor($subject);
}
示例8: getInData
/**
* Creates a Semantic Data object with the incoming properties instead of the
* usual outproperties.
*
* @return array(SMWSemanticData, bool) The semantic data including all inproperties, and if there are more inproperties left
*/
private function getInData()
{
$indata = new SemanticData($this->subject->getDataItem());
$propRequestOptions = new RequestOptions();
$propRequestOptions->sort = true;
$propRequestOptions->limit = $this->incomingPropertiesCount;
if ($this->offset > 0) {
$propRequestOptions->offset = $this->offset;
}
$incomingProperties = $this->store->getInProperties($this->subject->getDataItem(), $propRequestOptions);
$more = false;
if (count($incomingProperties) == $this->incomingPropertiesCount) {
$more = true;
array_pop($incomingProperties);
// drop the last one
}
$valRequestOptions = new RequestOptions();
$valRequestOptions->sort = true;
$valRequestOptions->limit = $this->incomingValuesCount;
foreach ($incomingProperties as $property) {
$values = $this->store->getPropertySubjects($property, $this->subject->getDataItem(), $valRequestOptions);
foreach ($values as $value) {
$indata->addPropertyObjectValue($property, $value);
}
}
// Added in 2.3
// Whether to show a more link or not can be set via
// SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate
\Hooks::run('SMW::Browse::AfterIncomingPropertiesLookupComplete', array($this->store, $indata, $valRequestOptions));
return array($indata, $more);
}
示例9: handleYetUnknownRedirectTarget
private function handleYetUnknownRedirectTarget(SemanticData $semanticData, DIWikiPage $target)
{
// Only keep the reference to safeguard that even in case of a text keeping
// its annotations there are removed from the Store. A redirect is not
// expected to contain any other annotation other than that of the redirect
// target
$subject = $semanticData->getSubject();
$semanticData = new SemanticData($subject);
$semanticData->addPropertyObjectValue(new DIProperty('_REDI'), $target);
// Force a manual changeTitle before the general update otherwise
// #redirect can cause an inconsistent data container as observed in #895
$this->store->changeTitle($subject->getTitle(), $target->getTitle(), $subject->getTitle()->getArticleID(), $target->getTitle()->getArticleID());
$dispatchContext = EventHandler::getInstance()->newDispatchContext();
$dispatchContext->set('title', $subject->getTitle());
EventHandler::getInstance()->getEventDispatcher()->dispatch('factbox.cache.delete', $dispatchContext);
return $semanticData;
}
示例10: typeChangeSemanticDataProvider
/**
* @return array
*/
public function typeChangeSemanticDataProvider()
{
$provider = array();
$title = \Title::newFromText(__METHOD__);
// #0 Single entry
$foo = new SemanticData(DIWikiPage::newFromTitle($title));
$foo->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fooQuex', 'Bar'));
$provider[] = array($foo, 'Has_fooQuex');
// #1 Single subobject entry
$foo = new SemanticData(DIWikiPage::newFromTitle($title));
$subobject = new Subobject($title);
$subobject->setSemanticData('Foo');
$subobject->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fomQuex', 'Bam'));
$foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$provider[] = array($foo, 'Has_fomQuex');
// #2 Combined
$foo = new SemanticData(DIWikiPage::newFromTitle($title));
$foo->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fooQuex', 'Bar'));
$foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$provider[] = array($foo, 'Has_fomQuex');
return $provider;
}
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:25,代码来源:SemanticDataSerializerDeserializerRoundtripTest.php
示例11: testAddSubobjectToSemanticDataForStorage
public function testAddSubobjectToSemanticDataForStorage()
{
$this->subjects[] = $subject = DIWikiPage::newFromTitle(Title::newFromText(__METHOD__));
$semanticData = new SemanticData($subject);
$subobject = new Subobject($subject->getTitle());
$subobject->setEmptyContainerForId('SomeSubobject');
$subobject->getSemanticData()->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Foo', 'Bar'));
$semanticData->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$this->getStore()->updateData($semanticData);
$expected = array('propertyCount' => 2, 'properties' => array(new DIProperty('Foo'), new DIProperty('_SKEY')), 'propertyValues' => array('Bar', __METHOD__));
$this->semanticDataValidator->assertThatPropertiesAreSet($expected, $this->getStore()->getSemanticData($subject)->findSubSemanticData('SomeSubobject'));
}
示例12: testForYetUnknownRedirectTarget
public function testForYetUnknownRedirectTarget()
{
$revision = $this->getMockBuilder('\\Revision')->disableOriginalConstructor()->getMock();
$wikiPage = $this->getMockBuilder('\\WikiPage')->disableOriginalConstructor()->getMock();
$wikiPage->expects($this->atLeastOnce())->method('getRevision')->will($this->returnValue($revision));
$pageCreator = $this->getMockBuilder('\\SMW\\MediaWiki\\PageCreator')->disableOriginalConstructor()->getMock();
$pageCreator->expects($this->atLeastOnce())->method('createPage')->will($this->returnValue($wikiPage));
$this->applicationFactory->registerObject('PageCreator', $pageCreator);
$subject = new DIWikiPage('Foo', NS_MAIN);
$target = new DIWikiPage('Bar', NS_MAIN);
$store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$store->expects($this->once())->method('changeTitle')->with($this->equalTo($subject->getTitle()), $this->equalTo($target->getTitle()), $this->anything(), $this->anything());
$semanticData = new SemanticData($subject);
$semanticData->addPropertyObjectValue(new DIProperty('_REDI'), $target);
$instance = new StoreUpdater($store, $semanticData);
$instance->setUpdateJobsEnabledState(true);
$instance->doUpdate();
}
示例13: pushTo
/**
* @since 2.5
*
* @param SemanticData $semanticData
* @param DIContainer|null $container
*/
public function pushTo(SemanticData $semanticData, DIContainer $container = null)
{
if ($container === null) {
return;
}
$semanticData->addPropertyObjectValue(new DIProperty('_ERRC'), $container);
}
示例14: pushAnnotationsTo
/**
* @since 2.5
*
* @param SemanticData $semanticData
*/
public function pushAnnotationsTo(SemanticData $semanticData)
{
$this->addAnnotation();
$semanticData->addPropertyObjectValue($this->profileAnnotator->getProperty(), $this->profileAnnotator->getContainer());
}