本文整理匯總了PHP中eZContentObject::relatedContentObjectCount方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentObject::relatedContentObjectCount方法的具體用法?PHP eZContentObject::relatedContentObjectCount怎麽用?PHP eZContentObject::relatedContentObjectCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::relatedContentObjectCount方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: restoreXmlRelations
/**
* Parses the XML for the attributes in $classAttributeIdentifiers, and fixes the relations for $object
* @param eZContentObject $object
* @param array $classAttributeIdentifiers
* @return int The number of created relations
*/
function restoreXmlRelations(eZContentObject $object, array $classAttributeIdentifiers)
{
$currentVersion = $object->currentVersion();
$langMask = $currentVersion->attribute('language_mask');
$languageList = eZContentLanguage::decodeLanguageMask($langMask, true);
$languageList = $languageList['language_list'];
// nothing to do if the object isn't translated
if (count($languageList) < 2) {
return 0;
}
$attributeArray = $object->fetchAttributesByIdentifier($classAttributeIdentifiers, $currentVersion->attribute('version'), $languageList);
$embedRelationsCount = $object->relatedContentObjectCount(false, 0, array('AllRelations' => eZContentObject::RELATION_EMBED));
$linkRelationsCount = $object->relatedContentObjectCount(false, 0, array('AllRelations' => eZContentObject::RELATION_LINK));
$embeddedObjectIdArray = $linkedObjectIdArray = array();
foreach ($attributeArray as $attribute) {
$xmlText = eZXMLTextType::rawXMLText($attribute);
$dom = new DOMDocument('1.0', 'utf-8');
if (!$dom->loadXML($xmlText)) {
continue;
}
// linked objects
$linkedObjectIdArray = array_merge($linkedObjectIdArray, getRelatedObjectList($dom->getElementsByTagName('link')));
// embedded objects
$embeddedObjectIdArray = array_merge($embeddedObjectIdArray, getRelatedObjectList($dom->getElementsByTagName('embed')), getRelatedObjectList($dom->getElementsByTagName('embed-inline')));
}
$doCommit = false;
$restoredRelations = 0;
if (!empty($embeddedObjectIdArray)) {
$object->appendInputRelationList($embeddedObjectIdArray, eZContentObject::RELATION_EMBED);
$restoredRelations += count($embeddedObjectIdArray) - $embedRelationsCount;
$doCommit = true;
}
if (!empty($linkedObjectIdArray)) {
$object->appendInputRelationList($linkedObjectIdArray, eZContentObject::RELATION_LINK);
$restoredRelations += count($linkedObjectIdArray) - $linkRelationsCount;
$doCommit = true;
}
if ($doCommit) {
$object->commitInputRelations($currentVersion->attribute('version'));
}
return $restoredRelations;
}