_channels['student'] = new StudentChannel(); $this->_channels['admin'] = new AdminChannel(); } public function send(EmailBlueprint $blueprint): void { // Get the identifier string for this blueprint (e.g., "course_enrollment", "quiz_complete") $trigger_slug = $blueprint->getSlug(); foreach ($this->_channels as $channel_name => $channel_driver) { // Generate option key dynamically: e.g., 'acadlix_notify_onsite_course_enrollment' $option_key = "acadlix_notify_{$trigger_slug}_to_{$channel_name}"; // Check if this specific channel is enabled for this trigger in settings $is_enabled = acadlix()->helper()->acadlix_get_option($option_key) === 'yes'; if (!$is_enabled) { continue; } $method = $channel_name; if (method_exists($blueprint, $method)) { $payload = $blueprint->$method(); $channel_driver->send($payload); } } } public function blueprint(): Blueprint { if (is_null($this->_blueprint)) { $this->_blueprint = new Blueprint(); } return $this->_blueprint; } }