public function destroyAction() { $this->logger->entering(); $this->logger->info('Loading item from params'); $items = new Item(); $item = $this->_getParam('item'); $this->logger->info("Loading item by id"); $id = $item['id']; $item = $items->find($id)->current(); $this->logger->info('Ensure owned by user'); if ($this->session->user_id != $item->owner_id) { $this->logger->warn('User is not item owner'); $this->flash->notice = "Invalid Action"; $this->_redirect('/'); } $this->logger->info("Delete item by id {$id}"); $where = $this->db->quoteInto('id = ?', $id); $rows_affected = $items->delete($where); $this->logger->info('Delete item tag associations'); $items->deleteTags($id); $this->logger->info("Removing old item from search index"); ItemIndex::delete($item); $this->logger->info('Redirect to item index'); $this->_redirect('items'); $this->logger->exiting(); }