Example #1
0
 /**
  * Handle creation of new document.
  *
  * @return void
  */
 public function create()
 {
     $entry = $this->collection->newInstance()->set($this->getCriteria());
     $this->data['entry'] = $entry;
     if ($this->request->isPost()) {
         try {
             $result = $entry->set($this->request->getBody())->save();
             h('notification.info', $this->clazz . ' created.');
             h('controller.create.success', array('model' => $entry));
         } catch (Stop $e) {
             throw $e;
         } catch (Exception $e) {
             // no more set notification.error since notificationmiddleware will
             // write this later
             // h('notification.error', $e);
             h('controller.create.error', array('model' => $entry, 'error' => $e));
             // rethrow error to make sure notificationmiddleware know what todo
             throw $e;
         }
     }
 }