本文整理汇总了PHP中JModelLegacy::batch方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelLegacy::batch方法的具体用法?PHP JModelLegacy::batch怎么用?PHP JModelLegacy::batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelLegacy
的用法示例。
在下文中一共展示了JModelLegacy::batch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: batch
/**
* Method to run batch operations.
*
* @param JModelLegacy $model The model of the component being processed.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 12.2
*/
public function batch($model)
{
// Initialise variables.
$vars = $this->input->post->get('batch', array(), 'array');
$cid = $this->input->post->get('cid', array(), 'array');
// Build an array of item contexts to check
$contexts = array();
foreach ($cid as $id) {
// If we're coming from com_categories, we need to use extension vs. option
if (isset($this->extension)) {
$option = $this->extension;
} else {
$option = $this->option;
}
$contexts[$id] = $option . '.' . $this->context . '.' . $id;
}
// Attempt to run the batch operation.
if ($model->batch($vars, $cid, $contexts)) {
$this->setMessage(JText::_('JLIB_APPLICATION_SUCCESS_BATCH'));
return true;
} else {
$this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_FAILED', $model->getError()));
return false;
}
}