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


PHP BaseController::isValidRequest方法代码示例

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


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

示例1: createAction

 /**
  * Creates a product based on the data entered in the "new" action
  */
 public function createAction()
 {
     if (!parent::isValidRequest(new CountryValidation())) {
         return parent::redirect('country/new');
     }
     try {
         $code = trim($this->request->get('code'));
         $existingCountry = Country::findFirst(array('conditions' => 'code = ?0', 'bind' => array($code)));
         if ($existingCountry) {
             $this->flash->notice('Country with code <b>' . $code . '</b> address allready exists.');
             return parent::redirect('country/new');
         } else {
             $country = new Country();
             $country->code = $code;
             $country->name = trim($this->request->get('name'));
             $country->save();
             $this->flash->success('Country created succesfully.');
         }
     } catch (Exception $ex) {
         $this->flash->error('An error occured when trying to create the new Country.');
     }
     return $this->redirect('country');
     #$this->view->disable();
 }
开发者ID:sweetdevel,项目名称:pingaroo,代码行数:27,代码来源:CountryController.php

示例2: createAction

 /**
  * Creates a product based on the data entered in the "new" action
  */
 public function createAction()
 {
     $proxyList = $this->request->get('proxyId');
     if (!parent::isValidRequest(new BatchValidation()) || empty($proxyList)) {
         if (empty($proxyList)) {
             $this->flash->notice('Please select at least 1 proxy.');
         }
         return parent::redirect('batch/new', ['proxyId' => implode(',', $this->request->get('proxyId'))]);
     }
     try {
         $name = trim($this->request->get('name'));
         $existingBatch = Batch::findFirst(array('conditions' => 'name = ?0', 'bind' => array($name)));
         if ($existingBatch) {
             $this->flash->notice('Batch name allready exists.');
             return parent::redirect('batch/new', ['proxyId' => implode(',', $this->request->get('proxyId'))]);
         } else {
             $urlId = $this->request->get('address');
             $proxyIds = $this->request->get('proxyId');
             $batch = new Batch();
             $batch->urlId = $urlId;
             $batch->name = $name;
             $batch->save();
             # THE BIG KAHUNA :)
             if ($this->config->application->debug) {
                 set_time_limit(0);
             }
             BatchHelper::create($this->config, $batch->id, $urlId, $proxyIds);
             $this->flash->success('Batch created succesfully.');
         }
     } catch (\Exception $ex) {
         $this->flash->error('An error occured when trying to create the new batch.');
     }
     $returnUrl = isset($batch) ? 'batch?batchId=' . $batch->id : 'batch';
     return $this->redirect($returnUrl);
     #$this->view->disable();
 }
开发者ID:sweetdevel,项目名称:pingaroo,代码行数:39,代码来源:BatchController.php

示例3: saveAction

 /**
  * Updates a product based on the data entered in the "edit" action
  */
 public function saveAction($id)
 {
     if (!parent::isValidId($id) || !parent::isValidRequest(new ProxyValidation())) {
         return parent::redirect('proxy/edit/' . $id);
     }
     try {
         $address = trim($this->request->get('address'));
         $existingProxy = Proxy::findFirst(array('conditions' => 'address = ?0', 'bind' => array($address)));
         if (isset($existingProxy->id) && $existingProxy->id != $id) {
             $this->flash->notice('Proxy exists with same address.');
             return parent::redirect('proxy/edit/' . $id);
         } else {
             $proxy = Proxy::findFirst($id);
             $proxy->countryId = $this->request->get('countryId');
             $proxy->address = $address;
             $proxy->save();
             $this->flash->success('Proxy updated succesfully.');
         }
     } catch (\Exception $ex) {
         $this->flash->error('An error occured when trying to update the proxy.');
     }
     return $this->redirect('proxy');
 }
开发者ID:sweetdevel,项目名称:pingaroo,代码行数:26,代码来源:ProxyController.php

示例4: saveAction

 /**
  * Updates a product based on the data entered in the "edit" action
  */
 public function saveAction($id)
 {
     if (!parent::isValidId($id) || !parent::isValidRequest(new UrlValidation())) {
         return parent::redirect('url/edit/' . $id);
     }
     try {
         $address = $this->request->get('address');
         $existingUrl = Url::findFirst(array('conditions' => 'address = ?0', 'bind' => array($address)));
         if (isset($existingUrl->id) && $existingUrl->id != $id) {
             $this->flash->notice('Url exists with same address.');
             return parent::redirect('url/edit/' . $id);
         } else {
             $url = Url::findFirst($id);
             $url->address = $address;
             $url->save();
             $this->flash->success('Url updated succesfully.');
         }
     } catch (\Exception $ex) {
         $this->flash->error('An error occured when trying to update the url.');
     }
     return $this->redirect('url');
 }
开发者ID:sweetdevel,项目名称:pingaroo,代码行数:25,代码来源:UrlController.php


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