当前位置: 首页>>代码示例>>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;未经允许,请勿转载。