public function removeItem($key)
{
// get our table name from the constructor
$tableName = $this->args[0];
// what are we doing?
$log = usingLog()->startAction("remove entry '{$key}' from {$tableName} table");
// get the table config
$tables = $this->getAllTables();
// make sure it exists
if (!isset($tables->{$tableName})) {
$msg = "table is empty / does not exist. '{$key}' not removed";
$log->endAction($msg);
return;
}
// make sure we have an entry to remove
if (!isset($tables->{$tableName}->{$key})) {
$msg = "table does not contain an entry for '{$key}'";
$log->endAction($msg);
return;
}
// remove the entry
unset($tables->{$tableName}->{$key});
// remove the table if it's empty
if (!count(get_object_vars($tables->{$tableName}))) {
$log->addStep("table '{$tableName}' is empty, removing from runtime config", function () use($tables, $tableName) {
unset($tables->{$tableName});
});
}
// save the changes
$this->st->saveRuntimeConfig();
// all done
$log->endAction();
}