public function eliminarAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin', array('controller' => 'relatori', 'action' => 'index')); } $producto = new Relatori(); $producto->setId($id); $this->getRelatoriDao()->eliminare($producto); return $this->redirect()->toRoute('admin', array('controller' => 'relatori', 'action' => 'index')); }
public function salvare(Relatori $relatori) { $data = array('nome' => $relatori->getNome(), 'cognome' => $relatori->getCognome(), 'email' => $relatori->getEmail(), 'link' => $relatori->getLink(), 'immagine' => $relatori->getImmagine(), 'titolo' => $relatori->getTitolo(), 'testo' => $relatori->getTesto(), 'stato' => $relatori->getStato()); $id = (int) $relatori->getId(); if ($id == 0) { $data['immagine'] = $relatori->getImmagine(); $this->tableGateway->insert($data); } else { if ($this->tuttiPerId($id)) { if ($data['immagine'] != null) { $data['immagine'] = $relatori->getImmagine(); } else { $data['immagine'] = $this->tuttiPerId($id)->getImmagine(); } $this->tableGateway->update($data, array('id' => $id)); } else { throw new \Exception('ID form non esistente'); } } }