/**
* Cleanup the Audit data
*
* @return int|void
*/
public function actionCleanup()
{
/** @var Audit $audit */
$audit = Yii::$app->getModule(Audit::findModuleIdentifier());
$panels = $this->panels !== null ? explode(',', $this->panels) : array_keys($audit->panels);
// summary
$this->preCleanupSummary($this->entry, $panels, $this->age);
// confirm
if ($this->confirm('Cleanup the above data?')) {
// cleanup panels
foreach ($panels as $id) {
if (!$this->cleanupPanel($id, $this->age)) {
$this->stdout("\nCleanup failed. The rest of the cleanups are canceled.\n", Console::FG_RED);
return self::EXIT_CODE_ERROR;
}
}
// cleanup audit_entry
if ($this->entry) {
if (!$this->cleanupEntry($this->age)) {
$this->stdout("\nCleanup failed.\n", Console::FG_RED);
return self::EXIT_CODE_ERROR;
}
}
// success!
$this->stdout("\nCleanup was successful.\n", Console::FG_GREEN);
}
return self::EXIT_CODE_NORMAL;
}