本文整理匯總了PHP中modResource::getIterator方法的典型用法代碼示例。如果您正苦於以下問題:PHP modResource::getIterator方法的具體用法?PHP modResource::getIterator怎麽用?PHP modResource::getIterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類modResource
的用法示例。
在下文中一共展示了modResource::getIterator方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateContextOfChildren
/**
* Updates the Context of all Children recursively to that of the parent.
*
* @static
* @param modX &$modx A reference to an initialized modX instance.
* @param modResource $parent The parent modResource instance.
* @param array $options An array of options.
* @return int The number of children updated.
*/
public static function updateContextOfChildren(modX &$modx, $parent, array $options = array())
{
$count = 0;
/** @var modResource $child */
foreach ($parent->getIterator('Children') as $child) {
$child->set('context_key', $parent->get('context_key'));
if ($child->save()) {
$count++;
} else {
$modx->log(modX::LOG_LEVEL_ERROR, "Could not change Context of child resource {$child->get('id')}", '', __METHOD__, __FILE__, __LINE__);
}
}
return $count;
}