getOptions(); $services = []; foreach ($subServices as $name => $subService) { $services[] = $this->getSubService($name, NotificationServiceInterface::class); } return $services; } /** * @throws InvalidService * @throws InvalidServiceManagerException */ public function sendNotification(Notification $notification): Notification { $subServices = $this->getSubServices(); /** * @var NotificationServiceInterface $service */ foreach ($subServices as $service) { $service->sendNotification($notification); } return $notification; } /** * @return Notification[] * @throws InvalidService * @throws InvalidServiceManagerException * @throws NotListedNotification */ public function getNotifications(string $userId): array { $subServices = $this->getSubServices(); /** * @var NotificationServiceInterface $service */ foreach ($subServices as $service) { if (($list = $service->getNotifications($userId)) !== false) { return $list; } } throw new NotListedNotification(); } /** * @throws InvalidService * @throws InvalidServiceManagerException * @throws NotListedNotification */ public function getNotification(string $id): Notification { $subServices = $this->getSubServices(); /** * @var NotificationServiceInterface $service */ foreach ($subServices as $service) { if (($notification = $service->getNotification($id)) !== false) { return $notification; } } throw new NotListedNotification(); } /** * @throws InvalidService * @throws InvalidServiceManagerException * @throws NotListedNotification */ public function changeStatus(Notification $notification): bool { $subServices = $this->getSubServices(); /** * @var NotificationServiceInterface $service */ foreach ($subServices as $service) { if (($newNotification = $service->changeStatus($notification)) !== false) { return $newNotification; } } throw new NotListedNotification(); } /** * @throws InvalidService * @throws InvalidServiceManagerException * @throws NotListedNotification */ public function notificationCount(string $userId): array { $subServices = $this->getSubServices(); /** * @var NotificationServiceInterface $service */ foreach ($subServices as $service) { if (($newNotification = $service->notificationCount($userId)) !== false) { return $newNotification; } } throw new NotListedNotification(); } /** * @throws InvalidService * @throws InvalidServiceManagerException */ public function getVisibility(): bool { $subServices = $this->getSubServices(); /** * @var NotificationServiceInterface $service */ foreach ($subServices as $service) { if ($service->getVisibility()) { return true; } } return false; } /** * @throws InvalidService * @throws InvalidServiceManagerException */ public function provideSchema(SchemaCollection $schemaCollection): void { $subServices = $this->getSubServices(); foreach ($subServices as $service) { if ($service instanceof SchemaProviderInterface) { $service->provideSchema($schemaCollection); } } } }