mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-22 05:16:13 +01:00
parent
8200302d31
commit
d1420a21b3
1 changed files with 7 additions and 7 deletions
|
@ -39,7 +39,7 @@ final class CreateTestDataCommand extends Command
|
||||||
$this
|
$this
|
||||||
->setHelp('Create test data for the tea extension in an already existing page (sysfolder).')
|
->setHelp('Create test data for the tea extension in an already existing page (sysfolder).')
|
||||||
->addArgument(
|
->addArgument(
|
||||||
'pageId',
|
'pageUid',
|
||||||
InputArgument::REQUIRED,
|
InputArgument::REQUIRED,
|
||||||
'Existing sysfolder page id.'
|
'Existing sysfolder page id.'
|
||||||
)
|
)
|
||||||
|
@ -53,8 +53,8 @@ final class CreateTestDataCommand extends Command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
/** @var int $pageId */
|
/** @var int $pageUid */
|
||||||
$pageId = $input->getArgument('pageId') ?? 0;
|
$pageUid = $input->getArgument('pageUid') ?? 0;
|
||||||
/** @var bool $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';
|
||||||
|
@ -62,19 +62,19 @@ final class CreateTestDataCommand extends Command
|
||||||
|
|
||||||
if ($deleteDataBefore) {
|
if ($deleteDataBefore) {
|
||||||
$query = $connectionForTable;
|
$query = $connectionForTable;
|
||||||
$query->delete($table, ['pid' => $pageId], [Connection::PARAM_INT]);
|
$query->delete($table, ['pid' => $pageUid], [Connection::PARAM_INT]);
|
||||||
$output->writeln(sprintf('Existing data in page %s deleted.', $pageId));
|
$output->writeln(sprintf('Existing data in page %s deleted.', $pageUid));
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $connectionForTable;
|
$query = $connectionForTable;
|
||||||
foreach ($this->teaData as $item) {
|
foreach ($this->teaData as $item) {
|
||||||
$item = ['pid' => $pageId, ...$item];
|
$item = ['pid' => $pageUid, ...$item];
|
||||||
$query->insert(
|
$query->insert(
|
||||||
$table,
|
$table,
|
||||||
$item
|
$item
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$output->writeln(sprintf('Test data in page %s created.', $pageId));
|
$output->writeln(sprintf('Test data in page %s created.', $pageUid));
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue