本文整理汇总了PHP中eZSearch::removeNodes方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSearch::removeNodes方法的具体用法?PHP eZSearch::removeNodes怎么用?PHP eZSearch::removeNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSearch
的用法示例。
在下文中一共展示了eZSearch::removeNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeNodes
/**
* Removes nodes
*
* This function does not check about permissions, this is the responsibility of the caller!
*
* @param array $removeNodeIdList Array of Node ID to remove
*
* @return array An array with operation status, always true
*/
public static function removeNodes(array $removeNodeIdList)
{
$mainNodeChanged = array();
$nodeAssignmentIdList = array();
$objectIdList = array();
$db = eZDB::instance();
$db->begin();
foreach ($removeNodeIdList as $nodeId) {
$node = eZContentObjectTreeNode::fetch($nodeId);
$objectId = $node->attribute('contentobject_id');
foreach (eZNodeAssignment::fetchForObject($objectId, eZContentObject::fetch($objectId)->attribute('current_version'), 0, false) as $nodeAssignmentKey => $nodeAssignment) {
if ($nodeAssignment['parent_node'] == $node->attribute('parent_node_id')) {
$nodeAssignmentIdList[$nodeAssignment['id']] = 1;
}
}
if ($nodeId == $node->attribute('main_node_id')) {
$mainNodeChanged[$objectId] = 1;
}
$node->removeThis();
if (!isset($objectIdList[$objectId])) {
$objectIdList[$objectId] = eZContentObject::fetch($objectId);
}
}
eZNodeAssignment::purgeByID(array_keys($nodeAssignmentIdList));
foreach (array_keys($mainNodeChanged) as $objectId) {
$allNodes = $objectIdList[$objectId]->assignedNodes();
// Registering node that will be promoted as 'main'
$mainNodeChanged[$objectId] = $allNodes[0];
eZContentObjectTreeNode::updateMainNodeID($allNodes[0]->attribute('node_id'), $objectId, false, $allNodes[0]->attribute('parent_node_id'));
}
// Give other search engines that the default one a chance to reindex
// when removing locations.
if (!eZSearch::getEngine() instanceof eZSearchEngine) {
foreach (array_keys($objectIdList) as $objectId) {
eZContentOperationCollection::registerSearchObject($objectId);
}
}
$db->commit();
//call appropriate method from search engine
eZSearch::removeNodes($removeNodeIdList);
$userClassIdList = eZUser::contentClassIDs();
foreach ($objectIdList as $objectId => $object) {
eZContentCacheManager::clearObjectViewCacheIfNeeded($objectId);
// clear user policy cache if this was a user object
if (in_array($object->attribute('contentclass_id'), $userClassIdList)) {
eZUser::purgeUserCacheByUserId($object->attribute('id'));
}
}
// we don't clear template block cache here since it's cleared in eZContentObjectTreeNode::removeNode()
return array('status' => true);
}