userIds = $userIds; $this->contextId = $contextId; $this->issueId = $issueId; } public function handle() { $contextDao = Application::getContextDAO(); $context = $contextDao->getById($this->contextId); /** @var Journal $context */ $issue = Repo::issue()->get($this->issueId, $this->contextId); if (!$context || !$issue) { return; } $locale = $context->getPrimaryLocale(); $template = Repo::emailTemplate()->getByKey($this->contextId, OpenAccessNotify::getEmailTemplateKey()); foreach ($this->userIds as $userId) { $user = Repo::user()->get($userId); if (!$user) { continue; } $notificationManager = new NotificationManager(); $notification = $notificationManager->createNotification( null, $userId, Notification::NOTIFICATION_TYPE_OPEN_ACCESS, $this->contextId ); $mailable = new OpenAccessNotify($context, $issue); $mailable ->subject($template->getLocalizedData('subject', $locale)) ->body($template->getLocalizedData('body', $locale)) ->from($context->getData('contactEmail'), $context->getData('contactName')) ->recipients([$user]) ->allowUnsubscribe($notification); Mail::send($mailable); } } }