public function eliminarAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('admin', array('controller' => 'contenuti', 'action' => 'index')); } $producto = new Contenuti(); $producto->setId($id); $this->getContenutiDao()->eliminare($producto); return $this->redirect()->toRoute('admin', array('controller' => 'contenuti', 'action' => 'index')); }
public function salvare(Contenuti $contenuti) { $data = array('titolo' => $contenuti->getTitolo(), 'contenuto' => $contenuti->getContenuto(), 'background' => $contenuti->getBackground(), 'posizione' => $contenuti->getPosizione(), 'tipo' => $contenuti->getTipo(), 'stato' => $contenuti->getStato()); if ($contenuti->getPosterlab() !== null) { $data['posterlab_id'] = $contenuti->getPosterlab()->getId(); } $id = (int) $contenuti->getId(); if ($id == 0) { $data['background'] = $contenuti->getBackground(); $this->tableGateway->insert($data); } else { if ($this->tuttiPerId($id)) { //$imagenalmacen= ; if ($data['background'] != null) { $data['background'] = $contenuti->getBackground(); } else { $data['background'] = $this->tuttiPerId($id)->getBackground(); } $this->tableGateway->update($data, array('id' => $id)); } else { throw new \Exception('ID form non esistente'); } } }