本文整理汇总了PHP中eZSearch::updateObjectState方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSearch::updateObjectState方法的具体用法?PHP eZSearch::updateObjectState怎么用?PHP eZSearch::updateObjectState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSearch
的用法示例。
在下文中一共展示了eZSearch::updateObjectState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateObjectState
/**
* Update a contentobject's state
*
* @param int $objectID
* @param int $selectedStateIDList
*
* @return array An array with operation status, always true
*/
public static function updateObjectState($objectID, $selectedStateIDList)
{
$object = eZContentObject::fetch($objectID);
// we don't need to re-assign states the object currently already has assigned
$currentStateIDArray = $object->attribute('state_id_array');
$selectedStateIDList = array_diff($selectedStateIDList, $currentStateIDArray);
// filter out any states the current user is not allowed to assign
$canAssignStateIDList = $object->attribute('allowed_assign_state_id_list');
$selectedStateIDList = array_intersect($selectedStateIDList, $canAssignStateIDList);
foreach ($selectedStateIDList as $selectedStateID) {
$state = eZContentObjectState::fetchById($selectedStateID);
$object->assignState($state);
}
//call appropriate method from search engine
eZSearch::updateObjectState($objectID, $selectedStateIDList);
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
return array('status' => true);
}