本文整理匯總了PHP中Cake\ORM\Table::processAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::processAction方法的具體用法?PHP Table::processAction怎麽用?PHP Table::processAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\ORM\Table
的用法示例。
在下文中一共展示了Table::processAction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
/**
* Process action.
*
* @param Table $table
* @param $action
* @param array $ids
* @param array $options
* @return \Cake\Network\Response|void
*/
public function process(Table $table, $action, array $ids = [], array $options = [])
{
$idsCount = count($ids);
$options = Hash::merge($this->_config, $options);
$_options = ['messages' => $this->__setupMessages($idsCount)];
$options = Hash::merge($_options, $options);
$redirect = $options['redirect'];
$messages = $options['messages'];
if (!$action) {
$this->Flash->error($messages['noAction']);
return $this->_controller->redirect($redirect);
}
if ($idsCount == 0) {
$this->Flash->error($messages['noChose']);
return $this->_controller->redirect($redirect);
}
$behaviors = $table->behaviors();
if (!in_array('BulkProcess', $behaviors->loaded())) {
$behaviors->load('Union/Core.BulkProcess');
}
$event = Event::dispatch($this->_getEventName($action, 'bulkBefore'), $this->_controller, ['ids' => $ids]);
if (is_array($event->result)) {
$ids = $event->result;
if (count($ids) == 0) {
$this->Flash->error($messages['noChose']);
return $this->_controller->redirect($redirect);
}
$messages = $this->__setupMessages(count($ids));
}
$process = $table->processAction($action, $ids);
if ($process) {
if (!empty($messages[$action])) {
$message = $messages[$action];
} else {
$message = __d('union', '{0} processed', Inflector::humanize($this->_controller->name));
}
Event::dispatch($this->_getEventName($action), $this->_controller, ['ids' => $ids]);
$this->Flash->success($message);
return $this->_controller->redirect($redirect);
}
$this->Flash->error(__d('union', 'An error occurred'));
return $this->_controller->redirect($redirect);
}