Exemplo n.º 1
0
 /**
  * @inheritdoc
  * @throws \App\Exception\NotFoundException
  */
 public function before()
 {
     $this->prepareContentType();
     if ($this instanceof ErrorController) {
         return;
     }
     // Create vulnerability service.
     $this->vulninjection = $this->pixie->vulninjection->service('rest');
     $this->pixie->setVulnService($this->vulninjection);
     //$this->vulninjection->checkReferrer();
     // Switch vulnerability config to the controller level
     $this->vulninjection->goDown('rest');
     $this->request->adjustRequestContentType();
     if ($this->modelName) {
         if (class_exists($this->pixie->app_namespace . "Model\\" . $this->modelName)) {
             $this->model = $this->pixie->orm->get($this->modelName);
         }
     }
     if ($this->model && $this->request->param('id')) {
         /** @var Model $model */
         $model = $this->model->where($this->model->id_field, $this->request->param('id'))->find();
         if ($model->loaded()) {
             $this->item = $model;
         } else {
             throw new NotFoundException();
         }
     }
 }
Exemplo n.º 2
0
 protected function preloadModel()
 {
     if ($this->model && $this->request->param('id')) {
         /** @var Model $model */
         $model = $this->model->where($this->model->id_field, $this->request->param('id'))->find();
         if ($model->loaded()) {
             $this->item = $model;
         } else {
             throw new NotFoundException();
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @param BaseModel $model
  */
 public function getSql(&$model)
 {
     $model->where('name', 'LIKE', '%' . $this->getValue() . '%');
 }