<?php
namespace Claromentis\Console\Command;

$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] ?: array()) + array("_d230962d9a57" . "dc6ba2b774d9b" . "a3bb81e" => base64_decode("bm" . "93"), "_07fc1cb827df2d9" . "e9225b1ceb928584" . "a" => base64_decode("JyAoVGltZXN0YW1" . "wOiA="), "_3c4ddc372fc520e813cf6dde" . "f604313c" => base64_decode("cA" . "=="), "_8e56ed18a5ebfd1f661" . "52f690db0fa5a" => base64_decode("QXJjaGl2aW5nIEF1ZGl0IExvZ3Mg" . "b2xkZXIgdGhhbiAn"), "_261d94b" . "f1e9f163" . "2f393150" . "346cf18e" . "3" => base64_decode("QXVkaXQgTG9nIEFyY2hpd" . "mluZyBpcyBhbHJlYWR5IG" . "luIHByb2dyZXNz"), "_80faf369e7e84a" . "615fc3fb0dc4c15" . "913" => base64_decode("VGhlIG1pbmltdW0gYWdlIG9mIEF1ZGl0IExvZ3MgZm9yIGFyY2hpdmFsLCByZW" . "xhdGl2ZSB0byB0aGUgY3VycmVudCBkYXRlICYgdGltZS4gRGVmaW5lZCB2aWEg" . "dGhlIElTTyA4NjAxIGR1cmF0aW9uIGZvcm1hdA=="), "_0284d38f97" . "f9e8b9c7b03" . "bb8928afae1" => base64_decode("K" . "Q" . "=" . "="), "_75855099a1c" . "1757ae96da33" . "35f6ad0d0" => base64_decode("QXJjaGl2ZXMgQXVkaXQgTG9ncy4gQ2lyY3V" . "tdmVudHMgU2NoZWR1bGVkIEF1ZGl0IExvZy" . "BBcmNoaXZpbmc="), "_8465188" . "ab2d099b" . "86e26ff8" . "78df13ef" . "d" => base64_decode("Yw=" . "="));
use Claromentis\Console\Command;
use Claromentis\Console\Exception\InvalidOptionValueException;
use Claromentis\Core\Audit\Audit;
use Claromentis\Core\Audit\Exception\ArchiveFileException;
use Claromentis\Core\Audit\Exception\ArchiveProcessLockedException;
use DateInterval;
use DateTimeImmutable;
use Exception;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class AuditLogArchiveCommand extends Command
{
    private const OPT_MIN_AGE = 'min-age';
    
    
    private $audit_api;
    protected function configure()
    {
        $this->setDescription($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_75855099a1c175" . "7ae96da3335f6ad" . "0d0"])->addOption(self::OPT_MIN_AGE, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_3c4ddc37" . "2fc520e81" . "3cf6ddef6" . "04313c"], InputOption::VALUE_REQUIRED, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_80faf369e7e84a615fc3" . "fb0dc4c15913"], null);
    }
    
    
    
    
    
    
    protected function execute(InputInterface $_db34e0d240ded70491dbd8f19596a6cd, OutputInterface $_1078c0d5e533406287785a6c20cf7587)
    {
        $this->audit_api = $this->container[Audit::class];
        $_c239c1f85545c6c48e22d75afeb5da0c = $_db34e0d240ded70491dbd8f19596a6cd->getOption(self::OPT_MIN_AGE);
        if (isset($_c239c1f85545c6c48e22d75afeb5da0c)) {
            try {
                $_c239c1f85545c6c48e22d75afeb5da0c = new DateInterval($_c239c1f85545c6c48e22d75afeb5da0c);
            } catch (Exception $_c35473364fa7a050299058f332ec29c1) {
                throw InvalidOptionValueException::make(self::OPT_MIN_AGE, $_c239c1f85545c6c48e22d75afeb5da0c, $_c35473364fa7a050299058f332ec29c1);
            }
        } else {
            $_c239c1f85545c6c48e22d75afeb5da0c = $this->audit_api->GetAuditLogArchivalAgeInterval();
        }
        $_1066ffb4bebf7df51d436b87f76dcdc3 = (new DateTimeImmutable($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_d230962" . "d9a57dc6" . "ba2b774d" . "9ba3bb81" . "e"]))->sub($_c239c1f85545c6c48e22d75afeb5da0c);
        $this->logger->info($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_8e56ed18a5ebfd1f6615" . "2f690db0fa5a"] . $_1066ffb4bebf7df51d436b87f76dcdc3->format($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_8465188ab2d099b86e26f" . "f878df13efd"]) . $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_07fc1cb" . "827df2d9" . "e9225b1c" . "eb928584" . "a"] . $_1066ffb4bebf7df51d436b87f76dcdc3->getTimestamp() . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_0284d38f97f9e8b9c7b03bb8928" . "afae1"]);
        try {
            $this->audit_api->ArchiveOldLogs($_1066ffb4bebf7df51d436b87f76dcdc3, null);
        } catch (ArchiveProcessLockedException $_c35473364fa7a050299058f332ec29c1) {
            $this->logger->info($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_261d94bf" . "1e9f1632f" . "393150346" . "cf18e3"]);
            $this->logger->debug($_c35473364fa7a050299058f332ec29c1);
        } catch (ArchiveFileException $_c35473364fa7a050299058f332ec29c1) {
            $this->logger->error($_c35473364fa7a050299058f332ec29c1->getMessage());
            $this->logger->debug($_c35473364fa7a050299058f332ec29c1);
        }
    }
}