*/ private static array $templateMap = [ 'contact_form' => ContactFormTemplate::class, 'blank_form' => BlankFormTemplate::class, ]; /** * Get template class by template ID * * @param string $templateId * @return string|null Template class name or null if not found */ public static function getTemplateClass(string $templateId): ?string { return self::$templateMap[$templateId] ?? null; } /** * Get template data by template ID * * @param string $templateId * @return array|null Template data or null if not found */ public static function getTemplate(string $templateId): ?array { $templateClass = self::getTemplateClass($templateId); if (!$templateClass || !class_exists($templateClass)) { return null; } return $templateClass::getTemplate(); } /** * Get all template IDs * * @return array */ public static function getAllTemplateIds(): array { return array_keys(self::$templateMap); } /** * Check if template ID exists * * @param string $templateId * @return bool */ public static function hasTemplate(string $templateId): bool { return isset(self::$templateMap[$templateId]); } /** * Get all templates as associative array * * @return array> */ public static function getAllTemplates(): array { $templates = []; foreach (self::$templateMap as $templateId => $templateClass) { // Skip BlankFormTemplate from public template list if ($templateClass === BlankFormTemplate::class) { continue; } if (class_exists($templateClass)) { $templateData = $templateClass::getTemplate(); $templates[$templateId] = $templateData; } } return $templates; } }