public function deleteAction() { $id = $this->getRequest()->getParam('id'); if ($id === null) { $this->addErrorMessage($this->tr->_('ACTION_MISSING_ID')); return; } $model = new Default_Model_Error(); $model->delete($id); $this->addMessage($this->tr->_('ERROR_DELETE')); $this->_redirect('/errors'); }
public function deleteAction() { $id = $this->getRequest()->getParam('id'); if ($id === null) { $this->addErrorMessage('ID parameter is missing.'); return; } $model = new Default_Model_Error(); $model->delete($id); $this->addMessage('Error code deleted'); $this->_redirect('/errors'); }
/** * Delete an error * * This is the delete error method. It allows you to delete an error. * * @return void */ public function deleteAction() { $this->_helper->viewRenderer->setViewSuffix('txt'); // The options we are accepting for deleting $options = new Zend_Console_Getopt(array('name|n=s' => $this->tr->_('NAME'))); try { $options->parse(); } catch (Zend_Console_Getopt_Exception $e) { $this->view->message = $e->getUsageMessage(); return; } if ($options->name == '') { $this->view->message = $options->getUsageMessage(); return; } $error_name = strtoupper($options->name); $model = new Default_Model_Error(); $tempErrors = $model->getAll(); $error_id = null; foreach ($tempErrors as $key => $value) { if ($error_name == strtoupper($value['name'])) { $error_id = $value['hash']; break; } } if (!$error_id) { $this->view->message = $this->tr->_('COULD_NOT_DELETE_ERROR') . ': ' . $error_name . '. ' . $this->tr->_('COULD_NOT_FIND_MATCH') . '.' . PHP_EOL; return; } try { $model->delete($error_id); $this->view->message = $this->tr->_('SUCCESS_DELETE_ERROR') . ': ' . $error_name . PHP_EOL; } catch (RuntimeException $e) { $this->view->message = $this->tr->_('ERROR_DELETING_ERROR') . ': ' . $error_name . '. ' . $e->getMessage() . PHP_EOL; } }
/** * Delete an error * * This is the delete error method. It allows you to delete an error. * * @return void */ public function deleteAction() { $this->_helper->viewRenderer->setViewSuffix('txt'); // The options we are accepting for deleting $options = new Zend_Console_Getopt( array( 'name|n=s' => 'Name of the error.', ) ); try { $options->parse(); } catch (Zend_Console_Getopt_Exception $e) { $this->view->message = $e->getUsageMessage(); return; } if ($options->name == '') { $this->view->message = $options->getUsageMessage(); return; } $error_name = strtoupper($options->name); $model = new Default_Model_Error(); $tempErrors = $model->getAll(); $error_id = null; foreach ($tempErrors as $key => $value) { if ($error_name == strtoupper($value['name'])) { $error_id = $value['hash']; break; } } if (!$error_id) { $this->view->message = 'Could not delete error: ' . $error_name . '. Could not find match.' . PHP_EOL; return; } try { $model->delete($error_id); $this->view->message = 'Successfully deleted error: ' . $error_name . PHP_EOL; } catch (RuntimeException $e) { $this->view->message = 'Error deleting errror: ' . $error_name . '. ' . $e->getMessage() . PHP_EOL; } }