getUserId(); $lastExecutionDate = $message->getLastExecutionDateTime(); $currentDate = $message->getCurrentDateTime(); $user = $this->userRepository->find($userId); if (null === $user) { $this->logger->warning('[ScheduleDailyNotificationDigestHandler] User not found', [ 'user_id' => $userId, ]); throw new \InvalidArgumentException(sprintf('User with ID %s not found', $userId)); } // Get all notifications for this user between last execution and current date $notifications = $this->notificationRepository->findNotificationsForUserBetweenDates( $userId, $lastExecutionDate, $currentDate ); // Filter out notifications that should be sent in a daily digest $dailyNotifications = array_filter($notifications, fn ($notification) => $user->isNotificationDailyDigest($notification->getType())); if ([] === $dailyNotifications) { $this->logger->info('[ScheduleDailyNotificationDigestHandler] No daily notifications found for user', [ 'user_id' => $userId, ]); return; } $this->notificationMailer->sendDailyDigest($user, $dailyNotifications); $this->logger->info('[ScheduleDailyNotificationDigestHandler] Sent daily digest', [ 'user_id' => $userId, 'notification_count' => count($dailyNotifications), ]); } }