renderers[] = $accompanyingPeriodNotificationRenderer; $this->renderers[] = $activityNotificationRenderer; } public function getTemplate(Notification $notification) { return $this->getRenderer($notification)->getTemplate(); } public function getTemplateData(Notification $notification) { return $this->getRenderer($notification)->getTemplateData($notification); } private function getRenderer(Notification $notification) { foreach ($this->renderers as $renderer) { if ($renderer->supports($notification)) { return $renderer; } } throw new Exception('No renderer for ' . $notification); } }