Skip to content

Commit

Permalink
scheduler job und cli command erstellt
Browse files Browse the repository at this point in the history
  • Loading branch information
conpassione committed Feb 3, 2025
1 parent 229e0da commit 674a8c2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
49 changes: 49 additions & 0 deletions Classes/Command/ArchiveLitterCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Conpassione\Cpkm\Command;

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Core\Bootstrap;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;

#[Autoconfigure(tags: [
[
'name' => '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;
}
}
8 changes: 8 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

Conpassione\Cpkm\:
resource: '../Classes/*'
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 674a8c2

Please sign in to comment.