providers[$type])); } /** * Get provider for a given ACTION * * @param string $type * @return INotificationProvider * @throws NotificationProvider\ProviderNotAvailableException * @throws NotificationTypeDoesNotExistException */ public function getProvider(string $type):INotificationProvider { if (in_array($type, ReminderService::REMINDER_TYPES, true)) { if (isset($this->providers[$type])) { return $this->providers[$type]; } throw new ProviderNotAvailableException($type); } throw new NotificationTypeDoesNotExistException($type); } /** * Registers a new provider * * @param string $providerClassName * @throws QueryException */ public function registerProvider(string $providerClassName):void { $provider = \OC::$server->query($providerClassName); if (!$provider instanceof INotificationProvider) { throw new \InvalidArgumentException('Invalid notification provider registered'); } $this->providers[$provider::NOTIFICATION_TYPE] = $provider; } }