Skip to content

Commit

Permalink
Merge pull request #29 from xima-media/command-bulk-update
Browse files Browse the repository at this point in the history
feat: finalize bulk update command
  • Loading branch information
jackd248 authored Jan 2, 2025
2 parents 6575bfa + 10dfb33 commit b2c00f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Classes/Command/BulkUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected function configure(): void
->addArgument('uid', InputArgument::OPTIONAL, 'The uid to update.', 1)
->addArgument('status', InputArgument::OPTIONAL, 'The status uid to set. If empty, the status will be cleared.', null)
->addOption('recursive', 'r', InputOption::VALUE_OPTIONAL, 'Whether to update pages recursively.', false)
->addOption('assignee', 'a', InputOption::VALUE_REQUIRED, 'The backend user uid to set an assignee for this record.', null)
->addUsage('pages 1 4')
->setHelp('A command to perform a bulk operation to content planner entities.');
}
Expand All @@ -39,6 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$uid = (int)$input->getArgument('uid');
$status = (int)$input->getArgument('status');
$recursive = $input->getOption('recursive') !== false;
$assignee = $input->getOption('assignee');
$statusEntity = null;

if ($status === 0) {
Expand All @@ -60,13 +62,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int

foreach ($uids as $uid) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder
$query = $queryBuilder
->update($table)
->set('tx_ximatypo3contentplanner_status', $status)
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \TYPO3\CMS\Core\Database\Connection::PARAM_INT))
)
->executeStatement();
;
if ($assignee !== null) {
if ($assignee === 0) {
$assignee = null;
}
$query->set('tx_ximatypo3contentplanner_assignee', $assignee);
}
$query->executeStatement();

$count++;
}
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ The content planner abilities are part of a **custom permission** and needed to

Every user can easily disable the content planner features in the user settings to avoid colour overload.

## Command

Use the bulk update command to process multiple entities at once. See help for more information regarding the specific usage.

```bash
vendor/bin/typo3 content-planner:bulk-update --help
```

## Additional record tables

If you want to extend the content planner to other record tables (e.g. news), follow the steps below:
Expand Down

0 comments on commit b2c00f0

Please sign in to comment.