示例#1
0
 /**
  * Save the data and return the model.
  *
  * @return Model
  */
 public function save()
 {
     if (!$this->isPermitted()) {
         throw new AccessDeniedException();
     }
     $repo = $this->form->getRepository();
     $model = $this->id ? $repo->find($this->id) : $this->form->newModel();
     $repo->save($model, $this->getCleanedInput(), function ($model) {
         $this->fillModel($model);
         $this->executeCustomAction($model);
         // The event is fired when every field is filled
         $this->fireSavingEvent($model);
     });
     $this->saveInner($model);
     $this->fireSavedEvent($model);
     return $model;
 }