-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scheduler job und cli command erstellt
- Loading branch information
1 parent
229e0da
commit 674a8c2
Showing
3 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters