本文整理汇总了PHP中SMW\SemanticData::getSubSemanticData方法的典型用法代码示例。如果您正苦于以下问题:PHP SemanticData::getSubSemanticData方法的具体用法?PHP SemanticData::getSubSemanticData怎么用?PHP SemanticData::getSubSemanticData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\SemanticData
的用法示例。
在下文中一共展示了SemanticData::getSubSemanticData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromSemanticData
/**
* @since 2.4
*
* @param SemanticData $semanticData
*
* @return string
*/
public static function createFromSemanticData(SemanticData $semanticData)
{
$hash = array();
$hash[] = $semanticData->getSubject()->getSerialization();
foreach ($semanticData->getProperties() as $property) {
$hash[] = $property->getKey();
foreach ($semanticData->getPropertyValues($property) as $di) {
$hash[] = $di->getSerialization();
}
}
foreach ($semanticData->getSubSemanticData() as $data) {
$hash[] = $data->getHash();
}
sort($hash);
return md5(implode('#', $hash));
}
示例2: testAddAndRemoveSubSemanticData
public function testAddAndRemoveSubSemanticData()
{
$title = Title::newFromText(__METHOD__);
$instance = new SemanticData(DIWikiPage::newFromTitle($title));
// Adds only a subobject reference to the container
$subobject = $this->newSubobject($title);
$instance->addSubobject($subobject);
$this->assertInternalType('array', $instance->getSubSemanticData());
foreach ($instance->getSubSemanticData() as $subSemanticData) {
$this->assertInstanceOf('SMWContainerSemanticData', $subSemanticData);
$this->assertEquals($subSemanticData, $subobject->getSemanticData());
}
$instance->removeSubSemanticData($subobject->getSemanticData());
$this->assertNotInstanceOf('SMWContainerSemanticData', $instance->getSubSemanticData());
}
示例3: removeDataFrom
/**
* Removes data from the given SMWSemanticData.
* If the subject of the data that is to be removed is not equal to the
* subject of this SMWSemanticData, it will just be ignored (nothing to
* remove). Likewise, removing data that is not present does not change
* anything.
*
* @since 1.8
*
* @param SemanticData $semanticData
*/
public function removeDataFrom(SemanticData $semanticData)
{
if (!$this->mSubject->equals($semanticData->getSubject())) {
return;
}
foreach ($semanticData->getProperties() as $property) {
$values = $semanticData->getPropertyValues($property);
foreach ($values as $dataItem) {
$this->removePropertyObjectValue($property, $dataItem);
}
}
foreach ($semanticData->getSubSemanticData() as $semData) {
$this->removeSubSemanticData($semData);
}
}