From aab373a2d439bddff8d0d7004373807fc2aa03d3 Mon Sep 17 00:00:00 2001 From: Xavier Lacot Date: Tue, 19 Sep 2023 16:11:04 +0200 Subject: [PATCH] review comments - use correct types for this new field --- migrations/Version20230918170924.php | 1 + .../StandupMeetingReminderCrudController.php | 1 + src/Entity/StandupMeetingReminder.php | 16 ++++++++-------- src/StandupMeetingReminder/Sender.php | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/migrations/Version20230918170924.php b/migrations/Version20230918170924.php index b0e00cc..f34387a 100644 --- a/migrations/Version20230918170924.php +++ b/migrations/Version20230918170924.php @@ -26,6 +26,7 @@ public function getDescription(): string public function up(Schema $schema): void { $this->addSql('ALTER TABLE standup_meeting_reminder ADD forecast_clients LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\''); + $this->addSql('UPDATE standup_meeting_reminder SET forecast_clients="a:0:{}"'); } public function down(Schema $schema): void diff --git a/src/Controller/Admin/StandupMeetingReminderCrudController.php b/src/Controller/Admin/StandupMeetingReminderCrudController.php index aba5ecf..595341e 100644 --- a/src/Controller/Admin/StandupMeetingReminderCrudController.php +++ b/src/Controller/Admin/StandupMeetingReminderCrudController.php @@ -32,6 +32,7 @@ public function configureFields(string $pageName): iterable return [ AssociationField::new('slackTeam')->onlyOnIndex(), TextField::new('channelId')->onlyOnIndex(), + ArrayField::new('forecastClients')->onlyOnIndex(), ArrayField::new('forecastProjects')->onlyOnIndex(), TextField::new('updatedBy')->onlyOnIndex(), TextField::new('time'), diff --git a/src/Entity/StandupMeetingReminder.php b/src/Entity/StandupMeetingReminder.php index d178fa0..3635818 100644 --- a/src/Entity/StandupMeetingReminder.php +++ b/src/Entity/StandupMeetingReminder.php @@ -35,13 +35,13 @@ class StandupMeetingReminder private string $channelId; /** - * @var array + * @var array */ #[ORM\Column(type: 'array')] private array $forecastClients = []; /** - * @var array + * @var array */ #[ORM\Column(type: 'array')] private array $forecastProjects = []; @@ -98,15 +98,15 @@ public function setChannelId(string $channelId): self } /** - * @return array + * @return array */ - public function getForecastClients(): ?array + public function getForecastClients(): array { return $this->forecastClients; } /** - * @param array $forecastClients + * @param array $forecastClients */ public function setForecastClients(array $forecastClients): self { @@ -116,15 +116,15 @@ public function setForecastClients(array $forecastClients): self } /** - * @return array + * @return array */ - public function getForecastProjects(): ?array + public function getForecastProjects(): array { return $this->forecastProjects; } /** - * @param array $forecastProjects + * @param array $forecastProjects */ public function setForecastProjects(array $forecastProjects): self { diff --git a/src/StandupMeetingReminder/Sender.php b/src/StandupMeetingReminder/Sender.php index 0fa9ca0..fab2401 100644 --- a/src/StandupMeetingReminder/Sender.php +++ b/src/StandupMeetingReminder/Sender.php @@ -106,8 +106,8 @@ private function findParticipants(StandupMeetingReminder $standupMeetingReminder $projectId = $assignment->getProjectId(); if ( - (0 === \count((array) $standupMeetingReminder->getForecastClients()) || \in_array((string) $projects[$projectId]->getClientId(), $standupMeetingReminder->getForecastClients(), true)) - && (0 === \count((array) $standupMeetingReminder->getForecastProjects()) || \in_array((string) $projectId, $standupMeetingReminder->getForecastProjects(), true)) + (0 === \count($standupMeetingReminder->getForecastClients()) || \in_array((string) $projects[$projectId]->getClientId(), $standupMeetingReminder->getForecastClients(), true)) + && (0 === \count($standupMeetingReminder->getForecastProjects()) || \in_array((string) $projectId, $standupMeetingReminder->getForecastProjects(), true)) ) { if (null !== $assignment->getPersonId()) { $members[$people[$assignment->getPersonId()]->getEmail()] = $memberName = sprintf(