当前位置: 首页>>代码示例>>PHP>>正文


PHP SplSubject::getGateway方法代码示例

本文整理汇总了PHP中SplSubject::getGateway方法的典型用法代码示例。如果您正苦于以下问题:PHP SplSubject::getGateway方法的具体用法?PHP SplSubject::getGateway怎么用?PHP SplSubject::getGateway使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplSubject的用法示例。


在下文中一共展示了SplSubject::getGateway方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 public function update(\SplSubject $subject)
 {
     $viewConfig = $subject->getViewConfigVerify();
     $query = $subject->getQueryServiceVerify()->get($viewConfig->query)->setParams($subject->getParams())->process();
     $models = $subject->getGateway()->find($query->getWhere());
     foreach ($models as $model) {
         $subject->getLogicServiceVerify()->get($viewConfig->mode, $viewConfig->model)->trigger($model->getDataModel());
     }
     $subject->setRedirect($subject->refresh($viewConfig->title . ' successfull', '/common/mail/index.html'));
 }
开发者ID:modelframework,项目名称:modelframework,代码行数:10,代码来源:LogicObserver.php

示例2: update

 /**
  * @param \SplSubject|View $subject
  *
  * @throws \Exception
  */
 public function update(\SplSubject $subject)
 {
     $viewConfig = $subject->getViewConfigVerify();
     $modelRoute = strtolower($viewConfig->model);
     $request = $subject->getParams()->getController()->getRequest();
     $results = [];
     $results['view'] = $subject->getParam('view');
     $ids = $request->getPost('checkedid', null);
     if (!is_array($ids)) {
         $id = $subject->getParams()->fromRoute('id', 0);
         if ($id) {
             $ids = array($id);
         } else {
             $subject->setRedirect($subject->getParams()->getController()->redirect()->toRoute('common', ['data' => $modelRoute, 'view' => $results['view'] == 'delete' ? 'list' : 'recyclelist']));
             return;
         }
     }
     $results['ids'] = $ids;
     foreach ($ids as $id) {
         try {
             $results['items'][$id] = $subject->getGateway()->findOne(['_id' => $id]);
         } catch (\Exception $ex) {
             $subject->setRedirect($subject->refresh('Data is invalid ' . $ex->getMessage(), $this->url()->fromRoute('common', ['data' => $modelRoute, 'view' => 'list'])));
             return;
         }
     }
     if ($request->isPost()) {
         $delyes = $request->getPost('delyes', null);
         $delno = $request->getPost('delno', null);
         if ($delyes !== null) {
             $view = $subject->getViewConfigVerify()->mode;
             if (!in_array($view, ['delete', 'clean', 'restore'])) {
                 throw new \Exception('Action is not allowed');
             }
             $subject->getLogicServiceVerify()->get('pre' . $view, $viewConfig->model)->trigger($results['items']);
             $subject->getLogicServiceVerify()->get($view, $viewConfig->model)->trigger($results['items']);
             $subject->getLogicServiceVerify()->get('post' . $view, $viewConfig->model)->trigger($results['items']);
             $url = $subject->getParams()->fromPost('saurl')['back'];
             $output = null;
             if (isset($url['query'])) {
                 parse_str(parse_url($url)['query'], $output);
             }
             $temp = $subject->getGateway()->findOne(['_id' => $id]);
             if ($temp) {
                 if (isset($output['back']) && $temp->toArray()['status_id'] != Status::DELETED) {
                     $url = $subject->getSaUrlBack($output['back']);
                 }
             }
             if (!isset($url) || $view == 'clean') {
                 $url = $subject->getParams()->getController()->url()->fromRoute('common', ['data' => $modelRoute, 'view' => $results['view'] == 'delete' ? 'list' : 'recyclelist']);
             }
             $subject->setRedirect($subject->refresh(ucfirst($results['view']) . ' was successfull ', $url));
             return;
         }
         if ($delno !== null) {
             $subject->setRedirect($subject->getParams()->getController()->redirect()->toRoute('common', ['data' => $modelRoute, 'view' => $results['view'] == 'delete' ? 'list' : 'recyclelist']));
             return;
         }
     }
     $subject->setData($results);
 }
开发者ID:modelframework,项目名称:modelframework,代码行数:66,代码来源:RecycleObserver.php


注:本文中的SplSubject::getGateway方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。