/** * Perform **deletion** of a document by an ID given. * * @param mixed $id * * @return void */ public function delete($id) { $id = explode(',', $id); if ($this->request->isPost() || $this->request->isDelete()) { $single = false; if (count($id) === 1) { $single = true; } try { $this->data['entries'] = array(); foreach ($id as $value) { $model = $this->collection->findOne($value); if (is_null($model)) { if ($single) { $this->app->notFound(); } continue; } $model->remove(); $this->data['entries'][] = $model; } h('notification.info', $this->clazz . ' deleted.'); h('controller.delete.success', array('models' => $this->data['entries'])); } catch (Stop $e) { throw $e; } catch (Exception $e) { h('notification.error', $e); if (empty($model)) { $model = null; } h('controller.delete.error', array('error' => $e, 'model' => $model)); } } }