diff --git a/Classes/Command/ArchiveLitterCommand.php b/Classes/Command/ArchiveLitterCommand.php new file mode 100644 index 0000000..de90207 --- /dev/null +++ b/Classes/Command/ArchiveLitterCommand.php @@ -0,0 +1,49 @@ + 'console.command', + 'command' => 'cpkm:archive-litter', + 'description' => 'Archive litter', + ] +])] +class ArchiveLitterCommand extends Command +{ + protected function configure(): void { + $this->setHelp('Archives Litters'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + Bootstrap::initializeBackendAuthentication(); + + /* Update-Query MYSQL Syntax + update tx_cpkm_domain_model_litter set l_status = 100 + where (hidden = 0) AND (starttime = 0) AND (endtime = 0) + AND (l_status = 2) AND (l_date < (unix_timestamp(current_timestamp) - 86400*90)); + */ + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); + $queryBuilder = $connectionPool->getQueryBuilderForTable('tx_cpkm_domain_model_litter'); + $connection = $connectionPool->getConnectionByName('Default'); + $sql = 'update tx_cpkm_domain_model_litter set l_status = 100 where (hidden = 0) AND (starttime = 0) AND (endtime = 0) AND (l_status = 2) AND (l_date < (unix_timestamp(current_timestamp) - 86400*90));'; + $statement = $connection->executeStatement($sql); + + $io = new SymfonyStyle($input, $output); + $io->title('Archives Litters'); + $io->note($statement . ' Litter(s) archived successfully.'); + + return Command::SUCCESS; + } +} diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..eccb2b7 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + Conpassione\Cpkm\: + resource: '../Classes/*' diff --git a/composer.json b/composer.json index d73768f..88fbdfd 100644 --- a/composer.json +++ b/composer.json @@ -19,17 +19,17 @@ "minimum-stability": "dev", "prefer-stable" : true, "require": { - "conpassione/cpdevsite": "dev-main#1.0.2", + "conpassione/cpdevsite": "*", "typo3/cms-core": "^13" }, "autoload": { "psr-4": { - "Conpassione\\cpkm\\": "Classes" + "Conpassione\\Cpkm\\": "Classes" } }, "autoload-dev": { "psr-4": { - "Conpassione\\cpkm\\Tests\\": "Tests" + "Conpassione\\Cpkm\\Tests\\": "Tests" } }, "config": {