Delete Plugin Tables Function Help #13
-
@alfredbuehler @creecros could you please help? All the frontend is done, a button will be created to delete all the plugin tables for the plugin pulled from the JSON. Controller:ContentCleaner/Controller/PluginCleaningController.php Lines 48 to 74 in ea9d7e2 Model is here:ContentCleaner/Model/ApplicationCleaningModel.php Lines 254 to 271 in ea9d7e2 Button:Would this work? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Regarding the Model: Think about adding a dry-run mode, that just logs the SQL statements to execute. I'm not very familiar with all SQL dialects. |
Beta Was this translation helpful? Give feedback.
-
There's something wrong: After installing Wiki: |
Beta Was this translation helpful? Give feedback.
-
After analyzing things, my suggestion for the delete function looks like this: public function deletePluginTables()
{
$this->checkCSRFParam();
// Pull variable from button
$plugin_job_name = $this->request->getStringParam('plugin_job_name');
$plugin_tables = [];
// Match variable to json content
foreach ($this->helper->pluginCleaningHelper->getDeletablePlugins() as $plugin) {
if ($plugin['plugin_title'] === $plugin_job_name && isset($plugin['plugin_tables'])) {
$plugin_tables = $plugin['plugin_tables'];
break;
}
}
// Delete the tables
$success = true;
foreach ($plugin_tables as $table) {
if (!$this->applicationCleaningModel->delete($table)) {
$success = false;
break;
}
}
if ($success) {
$this->flash->success(t('DEEP CLEANING COMPLETE: Plugin tables were deleted successfully'));
} else {
$this->flash->failure(t('DEEP CLEANING FAILED: Plugin tables could not be deleted'));
}
$this->response->redirect($this->helper->url->to('ContentCleanerController', 'show', array('plugin' => 'ContentCleaner')));
} Unfortunately, I cannot do more. Sorry. |
Beta Was this translation helpful? Give feedback.
After analyzing things, my suggestion for the delete function looks like this: