mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-09-19 18:16:13 +02:00

[BUGFIX] Fix errors from php cs fixer

Related: #1120
This commit is contained in:
Karsten Nowak 2024-07-29 17:21:27 +02:00
parent f5fe3a81b0
commit 33ce1f2e66
2 changed files with 13 additions and 11 deletions

View file

@ -24,13 +24,13 @@ final class CreateTestDataCommand extends Command
[ [
'title' => 'Darjeeling', 'title' => 'Darjeeling',
'description' => 'I love that tea!', 'description' => 'I love that tea!',
'sys_language_uid' => 0 'sys_language_uid' => 0,
], ],
[ [
'title' => 'Earl Grey', 'title' => 'Earl Grey',
'description' => 'A nice tea!', 'description' => 'A nice tea!',
'sys_language_uid' => 0 'sys_language_uid' => 0,
] ],
]; ];
protected function configure(): void protected function configure(): void
{ {
@ -51,23 +51,24 @@ final class CreateTestDataCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
/** @var integer $pageId */ /** @var int $pageId */
$pageId = $input->getArgument('pageId') ?? 0; $pageId = $input->getArgument('pageId') ?? 0;
/** @var boolean $deleteDataBefore */ /** @var bool $deleteDataBefore */
$deleteDataBefore = $input->getOption('delete-data-before') ?? false; $deleteDataBefore = $input->getOption('delete-data-before') ?? false;
$table = 'tx_tea_domain_model_tea'; $table = 'tx_tea_domain_model_tea';
$connectionForTable = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table); $connectionForTable = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
if($deleteDataBefore) { if ($deleteDataBefore) {
$query = $connectionForTable; $query = $connectionForTable;
$query->delete($table, ['pid' => $pageId], [Connection::PARAM_INT]); $query->delete($table, ['pid' => $pageId], [Connection::PARAM_INT]);
$output->writeln(sprintf('Existing data in page %s deleted.',$pageId)); $output->writeln(sprintf('Existing data in page %s deleted.', $pageId));
} }
$query = $connectionForTable; $query = $connectionForTable;
foreach ($this->teaData as $item) { foreach ($this->teaData as $item) {
$item = ['pid' => $pageId, ...$item]; $item = ['pid' => $pageId, ...$item];
$query->insert($table, $query->insert(
$table,
$item $item
); );
} }

View file

@ -16,10 +16,11 @@ return static function (ContainerConfigurator $containerConfigurator) {
->exclude('../Classes/Domain/Model/*'); ->exclude('../Classes/Domain/Model/*');
$services->set(CreateTestDataCommand::class) $services->set(CreateTestDataCommand::class)
->tag('console.command', [ ->tag(
'console.command',
[
'command' => 'tea:createtestdata', 'command' => 'tea:createtestdata',
'description'=>'Create test data in existing sysfolder' 'description' => 'Create test data in existing sysfolder',
] ]
); );
}; };