/** * Delete an action * * This is the delete action method. It allows you to delete an action. * * @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 == '') { echo $options->getUsageMessage(); exit; } $action_name = ucfirst(strtolower($options->name)); $model = new Default_Model_Action(); $tempActions = $model->getList(); $action_id = null; foreach ($tempActions as $hash => $tempName) { if ($action_name == $tempName) { $action_id = $hash; break; } } if (!$action_id) { $this->view->message = $this->tr->_('COULD_NOT_DELETE_ACTION') . ': ' . $action_name . '. ' . $this->tr->_('COULD_NOT_FIND_MATCH') . PHP_EOL; return; } try { $model->delete($action_id); $this->view->message = $this->tr->_('SUCCESS_DELETE_ACTION') . ': ' . $action_name . PHP_EOL; } catch (RuntimeException $e) { $this->view->message = $this->tr->_('ERROR_DELETING_ACTION') . ': ' . $action_name . '. ' . $e->getMessage() . PHP_EOL; } }
/** * Delete an action * * This is the delete action method. It allows you to delete an action. * * @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 action.')); try { $options->parse(); } catch (Zend_Console_Getopt_Exception $e) { $this->view->message = $e->getUsageMessage(); return; } if ($options->name == '') { echo $options->getUsageMessage(); exit; } $action_name = ucfirst(strtolower($options->name)); $model = new Default_Model_Action(); $tempActions = $model->getList(); $action_id = null; foreach ($tempActions as $hash => $tempName) { if ($action_name == $tempName) { $action_id = $hash; break; } } if (!$action_id) { $this->view->message = 'Could not delete action: ' . $action_name . '. Could not find match.' . PHP_EOL; return; } try { $model->delete($action_id); $this->view->message = 'Successfully deleted action: ' . $action_name . PHP_EOL; } catch (RuntimeException $e) { $this->view->message = 'Error deleting action: ' . $action_name . '. ' . $e->getMessage() . PHP_EOL; } }