From 885b455e45c7a34e7d1dce74834890775ac05ee5 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Thu, 5 Oct 2023 11:11:54 +0200 Subject: [PATCH] TEAMMANAGE-2784: Added digital post id filter on envelope list command --- CHANGELOG.md | 2 ++ src/Command/DigitalPostEnvelopeListCommand.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca51217c..ed6a8b7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ about writing changes to this log. ## [Unreleased] +- [PR-382](https://github.com/itk-dev/naevnssekretariatet/pull/382) + Added `--digital-post-id` filter on `tvist1:digital-post-envelope:list`. - [PR-380](https://github.com/itk-dev/naevnssekretariatet/pull/380) Updated `itk-dev/openid-connect-bundle` to use authorization code flow. - [PR-380](https://github.com/itk-dev/naevnssekretariatet/pull/380) diff --git a/src/Command/DigitalPostEnvelopeListCommand.php b/src/Command/DigitalPostEnvelopeListCommand.php index 600183ef..6da8f243 100644 --- a/src/Command/DigitalPostEnvelopeListCommand.php +++ b/src/Command/DigitalPostEnvelopeListCommand.php @@ -37,6 +37,7 @@ protected function configure() { $this ->addOption('status', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with this status') + ->addOption('digital-post-id', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Digital post id') ->addOption('digital-post-subject', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with subject matching this LIKE expression') ->addOption('max-results', null, InputOption::VALUE_REQUIRED, 'Show at most this many envelopes', 10) ->addOption('id', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Envelope id') @@ -134,6 +135,14 @@ private function findEnvelopes(InputInterface $input): array ->setParameter('status', $status) ; } + if ($digitalPostIds = $input->getOption('digital-post-id')) { + $digitalPostIds = array_map(static fn (string $id) => Uuid::fromString($id)->toBinary(), $digitalPostIds); + $qb + ->join('e.digitalPost', 'p_id') + ->andWhere('p_id.id IN (:digitalPostIds)') + ->setParameter('digitalPostIds', $digitalPostIds) + ; + } if ($subject = $input->getOption('digital-post-subject')) { $qb ->join('e.digitalPost', 'p')