當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。