$message */ protected function createNotification( Access $access, string $name, NotificationTypeEnum $type, array $message, ?string $link = null ): Notification { $now = new \DateTime(); $notification = new Notification(); $notification->setName($name) ->setRecipientAccess($access) ->setRecipientOrganization($access->getOrganization()) ->setType($type) ->setMessage($message) ->setLink($link) ->setCreateDate($now) ->setUpdateDate($now); return $notification; } /** * @param array $message */ public function notify( Access $access, string $name, NotificationTypeEnum $type, array $message, ?string $link = null ): Notification { $notification = $this->createNotification($access, $name, $type, $message, $link); $this->em->persist($notification); $this->em->flush(); $this->mercureHub->publishCreate($access->getId(), $notification); return $notification; } public function notifyExport( Access $access, File $file ): Notification { return $this->notify( $access, 'export', NotificationTypeEnum::FILE, ['fileName' => $file->getName()], '/api/files/'.$file->getId().'/download' ); } /** * @param array $message */ public function notifyMessage( Access $access, array $message ): Notification { return $this->notify( $access, 'message', NotificationTypeEnum::MESSAGE, $message ); } /** * @param list $message */ public function notifySystem( Access $access, array $message ): Notification { return $this->notify( $access, 'message', NotificationTypeEnum::SYSTEM, $message ); } /** * @param list $message */ public function notifyError( Access $access, string $name, array $message ): Notification { return $this->notify( $access, $name, NotificationTypeEnum::ERROR, $message ); } }