當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Table::processAction方法代碼示例

本文整理匯總了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);
 }
開發者ID:Cheren,項目名稱:union,代碼行數:52,代碼來源:BulkProcessComponent.php


注:本文中的Cake\ORM\Table::processAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。