getMessage()); throw $e; } } /** * Get the rendered content of the contact form. * * This method renders the contact form view and returns the output as a string. * It is used for embedding the contact form in various parts of the application. * * @param array $data Optional data to pass to the contact form view. * @return string The rendered contact form HTML. * @throws \Exception If the contact form view cannot be rendered. */ protected function getContactForm(array $data = []): string { try { Logger::info("[DEBUG] Rendering contact form with data: " . json_encode($data)); // Buffer output to capture rendered content ob_start(); $this->render('partials/contact_form', $data); $output = ob_get_clean(); Logger::info("[DEBUG] Successfully rendered contact form"); return $output; } catch (\Exception $e) { // Log any exception that occurs Logger::error("[ERROR] Exception while rendering contact form: " . $e->getMessage()); throw $e; } } }