From fef95c412372e4b2bdf45963665ffbb976e1b8b1 Mon Sep 17 00:00:00 2001 From: sharmasahil Date: Thu, 21 Nov 2024 12:22:33 +1100 Subject: [PATCH] Removed default yes option and use custom option --- src/Command/AuditLogCleanupCommand.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Command/AuditLogCleanupCommand.php b/src/Command/AuditLogCleanupCommand.php index c4457089..15577b36 100755 --- a/src/Command/AuditLogCleanupCommand.php +++ b/src/Command/AuditLogCleanupCommand.php @@ -47,23 +47,22 @@ public static function create(ContainerInterface $container) { * @aliases tcl * @description Cleans up audittrail logs older than the configured retention period. * - * @option yes Skip confirmation and run the cleanup immediately. + * @option force-cleanup Skip confirmation and run the cleanup immediately. */ - public function cleanupLogs($options = ['yes' => FALSE]) { - // Check if the user passed the --yes option - if (!$options['yes']) { - // If the -y/--yes flag isn't passed, ask for confirmation. + public function cleanupLogs($options = ['force-cleanup' => FALSE]) { + // Check if the user passed the --force-cleanup option + if (!$options['force-cleanup']) { + // If the force-cleanup flag isn't passed, ask for confirmation. $confirmation = $this->confirmCleanup(); if (!$confirmation) { $this->output()->writeln('Cleanup operation cancelled.'); return; } } - + $config = $this->configFactory->get('tide_core.settings'); define('DEFAULT_LOG_RETENTION_DAYS', 30); $log_retention_days = $config->get('log_retention_days') ?: DEFAULT_LOG_RETENTION_DAYS; - // Get current date and time $current_time = new DateTime(); $current_time->sub(new DateInterval("P{$log_retention_days}D")); @@ -106,4 +105,3 @@ private function optimizeDatabase() { $this->output()->writeln("Database optimized to recover space."); } } -