PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / TemplateMapper.php

TemplateMapper.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/Services/Template/TemplateMapper.php

288 lines 17.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace IvyForms\Services\Template;
6
7 /**
8 * Class TemplateMapper
9 *
10 * Maps template IDs to their corresponding template classes
11 *
12 * @package IvyForms\Services\Template
13 */
14 class TemplateMapper
15 {
16 /**
17 * Template ID to class mapping
18 *
19 * @var array<string, string>
20 */
21 private static array $templateMap = [
22 'contact_form' => ContactFormTemplate::class,
23 'blank_form' => BlankFormTemplate::class,
24 'wedding_rsvp' => WeddingRsvpTemplate::class,
25 'anniversary_dinner_reservation_form' => AnniversaryDinnerReservationFormTemplate::class,
26 'birthday_dinner_reservation_form' => BirthdayDinnerReservationFormTemplate::class,
27 'private_dining_reservation_form' => PrivateDiningReservationFormTemplate::class,
28 'craft_vendor_registration_form' => CraftVendorRegistrationFormTemplate::class,
29 'food_vendor_registration_form' => FoodVendorRegistrationFormTemplate::class,
30 'fitness_class_registration_form' => FitnessClassRegistrationFormTemplate::class,
31 'yoga_class_registration_form' => YogaClassRegistrationFormTemplate::class,
32 'cooking_class_registration_form' => CookingClassRegistrationFormTemplate::class,
33 'conference_room_booking_form' => ConferenceRoomBookingFormTemplate::class,
34 'product_order_form' => ProductOrderFormTemplate::class,
35 'b2b_product_order_form' => B2bProductOrderFormTemplate::class,
36 'corporate_office_supplies_procurement_form' => CorporateOfficeSuppliesProcurementFormTemplate::class,
37 'product_customization_form' => ProductCustomizationFormTemplate::class,
38 'technology_innovation_summit_registration_form' => TechnologyInnovationSummitRegistrationFormTemplate::class,
39 'healthcare_medical_conference_registration_form' => HealthcareMedicalConferenceRegistrationFormTemplate::class,
40 'marketing_growth_leadership_conference_registration_form'
41 => MarketingGrowthLeadershipConferenceRegistrationFormTemplate::class,
42 'financial_services_fintech_leadership_conference_registration_form'
43 => FinancialServicesFintechLeadershipConferenceRegistrationFormTemplate::class,
44 'education_academic_research_conference_registration_form'
45 => EducationAcademicResearchConferenceRegistrationFormTemplate::class,
46 'cybersecurity_data_protection_conference_registration_form'
47 => CybersecurityDataProtectionConferenceRegistrationFormTemplate::class,
48 'technology_conference_event_feedback_form' => TechnologyConferenceEventFeedbackFormTemplate::class,
49 'healthcare_seminar_medical_event_feedback_form' => HealthcareSeminarMedicalEventFeedbackFormTemplate::class,
50 'marketing_networking_event_feedback_form' => MarketingNetworkingEventFeedbackFormTemplate::class,
51 'corporate_employee_training_feedback_form' => CorporateEmployeeTrainingFeedbackFormTemplate::class,
52 'technical_skills_workshop_feedback_form' => TechnicalSkillsWorkshopFeedbackFormTemplate::class,
53 'online_course_elearning_feedback_form' => OnlineCourseElearningFeedbackFormTemplate::class,
54 'medical_specialist_appointment_booking_form' => MedicalSpecialistAppointmentBookingFormTemplate::class,
55 'beauty_salon_personal_care_appointment_form' => BeautySalonPersonalCareAppointmentFormTemplate::class,
56 'business_consultation_strategy_session_booking_form'
57 => BusinessConsultationStrategySessionBookingFormTemplate::class,
58 'event_registration' => EventRegistrationTemplate::class,
59 'event_tshirt_order_form' => EventTShirtOrderFormTemplate::class,
60 'custom_tshirt_order_form' => CustomTShirtOrderFormTemplate::class,
61 'custom_cake_order_form' => CustomCakeOrderFormTemplate::class,
62 'wedding_cake_order_form' => WeddingCakeOrderFormTemplate::class,
63 'birthday_cake_order_form' => BirthdayCakeOrderFormTemplate::class,
64 'doctor_appointment_booking_form' => DoctorAppointmentBookingFormTemplate::class,
65 'dinner_reservation_form' => DinnerReservationFormTemplate::class,
66 'hair_salon_appointment_form' => HairSalonAppointmentFormTemplate::class,
67 'nail_salon_appointment_form' => NailSalonAppointmentFormTemplate::class,
68 'spa_appointment_booking_form' => SpaAppointmentBookingFormTemplate::class,
69 'consultation_appointment_form' => ConsultationAppointmentFormTemplate::class,
70 'birthday_tshirt_order_form' => BirthdayTShirtOrderFormTemplate::class,
71 'corporate_tshirt_order_form' => CorporateTShirtOrderFormTemplate::class,
72 'residential_construction_change_form' => ResidentialConstructionChangeFormTemplate::class,
73 'festival_waiver_form' => FestivalWaiverFormTemplate::class,
74 'charity_run_waiver_form' => CharityRunWaiverFormTemplate::class,
75 'volunteer_event_waiver_form' => VolunteerEventWaiverFormTemplate::class,
76 'community_event_waiver_form' => CommunityEventWaiverFormTemplate::class,
77 'school_trip_waiver_form' => SchoolTripWaiverFormTemplate::class,
78 'yoga_class_waiver_form' => YogaClassWaiverFormTemplate::class,
79 'dance_class_waiver_form' => DanceClassWaiverFormTemplate::class,
80 'hiking_trip_waiver_form' => HikingTripWaiverFormTemplate::class,
81 'gym_waiver_form' => GymWaiverFormTemplate::class,
82 'sports_event_waiver_form' => SportsEventWaiverFormTemplate::class,
83 'universal_construction_change_form' => UniversalConstructionChangeFormTemplate::class,
84 'maintenance_work_order_form' => MaintenanceWorkOrderFormTemplate::class,
85 'vacation_leave_request_form' => VacationLeaveRequestFormTemplate::class,
86 'sick_leave_request_form' => SickLeaveRequestFormTemplate::class,
87 'annual_leave_request_form' => AnnualLeaveRequestFormTemplate::class,
88 'maternity_leave_request_form' => MaternityLeaveRequestFormTemplate::class,
89 'conference_registration_form' => ConferenceRegistrationFormTemplate::class,
90 'webinar_registration_form' => WebinarRegistrationFormTemplate::class,
91 'corporate_photo_consent_form' => CorporatePhotoConsentFormTemplate::class,
92 'conference_photo_consent_form' => ConferencePhotoConsentFormTemplate::class,
93 'sports_team_photo_consent_form' => SportsTeamPhotoConsentFormTemplate::class,
94 'school_photo_consent_form' => SchoolPhotoConsentFormTemplate::class,
95 'event_photo_consent_form' => EventPhotoConsentFormTemplate::class,
96 'photo_video_consent_form' => PhotoVideoConsentFormTemplate::class,
97 'workshop_registration_form' => WorkshopRegistrationFormTemplate::class,
98 'charity_event_registration_form' => CharityEventRegistrationFormTemplate::class,
99 'baby_shower_cake_order_form' => BabyShowerCakeOrderFormTemplate::class,
100 'general_medical_consent_form' => GeneralMedicalConsentFormTemplate::class,
101 'surgery_informed_consent_form' => SurgeryInformedConsentFormTemplate::class,
102 'general_change_order_form' => GeneralChangeOrderFormTemplate::class,
103 'marketing_conference_registration_form' => MarketingConferenceRegistrationFormTemplate::class,
104 'medical_conference_registration_form' => MedicalConferenceRegistrationFormTemplate::class,
105 'tech_conference_registration_form' => TechConferenceRegistrationFormTemplate::class,
106 'blood_transfusion_consent_form' => BloodTransfusionConsentFormTemplate::class,
107 'vaccination_consent_form' => VaccinationConsentFormTemplate::class,
108 'anesthesia_consent_form' => AnesthesiaConsentFormTemplate::class,
109 'garden_wedding_rsvp_form' => GardenWeddingRSVPFormTemplate::class,
110 'beach_wedding_rsvp_form' => BeachWeddingRSVPFormTemplate::class,
111 'destination_wedding_rsvp_form' => DestinationWeddingRSVPFormTemplate::class,
112 'traditional_wedding_rsvp_form' => TraditionalWeddingRSVPFormTemplate::class,
113 'wedding_registration_form' => WeddingRegistrationFormTemplate::class,
114 'software_purchase_order_form' => SoftwarePurchaseOrderFormTemplate::class,
115 'office_supplies_purchase_order_form' => OfficeSuppliesPurchaseOrderFormTemplate::class,
116 'equipment_purchase_order_form' => EquipmentPurchaseOrderFormTemplate::class,
117 'material_purchase_order_form' => MaterialPurchaseOrderFormTemplate::class,
118 'education_conference_registration_form' => EducationConferenceRegistrationFormTemplate::class,
119 'repair_work_order_form' => RepairWorkOrderFormTemplate::class,
120 'installation_work_order_form' => InstallationWorkOrderFormTemplate::class,
121 'team_tshirt_order_form' => TeamTshirtOrderFormTemplate::class,
122 'kitchen_upgrade_change_form' => KitchenUpgradeChangeFormTemplate::class,
123 'commercial_construction_change_form' => CommercialConstructionChangeFormTemplate::class,
124 'hr_interview_feedback_form' => HRInterviewFeedbackFormTemplate::class,
125 'technical_role_interview_feedback_form' => TechnicalRoleInterviewFeedbackFormTemplate::class,
126 'candidate_evaluation_form' => CandidateEvaluationFormTemplate::class,
127 'technical_interview_feedback_form' => TechnicalInterviewFeedbackFormTemplate::class,
128 'course_content_feedback_form' => CourseContentFeedbackFormTemplate::class,
129 'trainer_feedback_form' => TrainerFeedbackFormTemplate::class,
130 'online_training_feedback_form' => OnlineTrainingFeedbackFormTemplate::class,
131 'employee_training_feedback_form' => EmployeeTrainingFeedbackFormTemplate::class,
132 'client_loyalty_testimonial_readiness_form' => ClientLoyaltyTestimonialReadinessFormTemplate::class,
133 'client_relationship_communication_feedback' => ClientRelationshipCommunicationFeedbackTemplate::class,
134 'general_client_feedback_form' => GeneralClientFeedbackFormTemplate::class,
135 'service_specific_client_feedback_form' => ServiceSpecificClientFeedbackFormTemplate::class,
136 'ongoing_client_feedback_form' => OngoingClientFeedbackFormTemplate::class,
137 'training_event_feedback_form' => TrainingEventFeedbackFormTemplate::class,
138 'networking_event_feedback_form' => NetworkingEventFeedbackFormTemplate::class,
139 'workshop_feedback_form' => WorkshopFeedbackFormTemplate::class,
140 'customer_loyalty_recommendation_form' => CustomerLoyaltyRecommendationFormTemplate::class,
141 'webinar_feedback_form' => WebinarFeedbackFormTemplate::class,
142 'conference_feedback_form' => ConferenceFeedbackFormTemplate::class,
143 'event_feedback_form' => EventFeedbackFormTemplate::class,
144 'post_purchase_feedback_form' => PostPurchaseFeedbackFormTemplate::class,
145 'website_experience_feedback_form' => WebsiteExperienceFeedbackFormTemplate::class,
146 'customer_support_feedback_form' => CustomerSupportFeedbackFormTemplate::class,
147 'product_feedback_form' => ProductFeedbackFormTemplate::class,
148 'project_completion_feedback_form' => ProjectCompletionFeedbackFormTemplate::class,
149 'digital_marketing_internship_application_form' => DigitalMarketingInternshipApplicationFormTemplate::class,
150 'software_engineering_internship_application_form'
151 => SoftwareEngineeringInternshipApplicationFormTemplate::class,
152 'warehouse_logistics_worker_application_form' => WarehouseLogisticsWorkerApplicationFormTemplate::class,
153 'marketing_specialist_job_application_form' => MarketingSpecialistJobApplicationFormTemplate::class,
154 'software_developer_job_application_form' => SoftwareDeveloperJobApplicationFormTemplate::class,
155 'commercial_rental_application_form' => CommercialRentalApplicationFormTemplate::class,
156 'student_housing_application_form' => StudentHousingApplicationFormTemplate::class,
157 'rental_application_form' => RentalApplicationFormTemplate::class,
158 'technical_contractor_application_form' => TechnicalContractorApplicationFormTemplate::class,
159 'creative_contractor_application_form' => CreativeContractorApplicationFormTemplate::class,
160 'freelancer_application_form' => FreelancerApplicationFormTemplate::class,
161 'remote_internship_application_form' => RemoteInternshipApplicationFormTemplate::class,
162 'corporate_internship_application_form' => CorporateInternshipApplicationFormTemplate::class,
163 'university_internship_application_form' => UniversityInternshipApplicationFormTemplate::class,
164 'skilled_trade_employment_application_form' => SkilledTradeEmploymentApplicationFormTemplate::class,
165 'retail_employment_application_form' => RetailEmploymentApplicationFormTemplate::class,
166 'corporate_employment_application_form' => CorporateEmploymentApplicationFormTemplate::class,
167 'skilled_professional_job_application_form' => SkilledProfessionalJobApplicationFormTemplate::class,
168 'entry_level_job_application_form' => EntryLevelJobApplicationFormTemplate::class,
169 'general_job_application_form' => GeneralJobApplicationFormTemplate::class,
170 'office_space_rental_application_form' => OfficeSpaceRentalApplicationFormTemplate::class,
171 'apartment_rental_application_form' => ApartmentRentalApplicationFormTemplate::class,
172 'ui_ux_designer_freelancer_application_form' => UiUxDesignerFreelancerApplicationFormTemplate::class,
173 'video_editor_freelancer_application_form' => VideoEditorFreelancerApplicationFormTemplate::class,
174 'custom_event_tshirt_bulk_order_form' => CustomEventTShirtBulkOrderFormTemplate::class,
175 'fashion_brand_custom_apparel_order_form' => FashionBrandCustomApparelOrderFormTemplate::class,
176 'sports_team_custom_jersey_tshirt_order_form' => SportsTeamCustomJerseyTShirtOrderFormTemplate::class,
177 'facility_maintenance_issue_report_form' => FacilityMaintenanceIssueReportFormTemplate::class,
178 'it_support_equipment_maintenance_form' => ItSupportEquipmentMaintenanceFormTemplate::class,
179 'property_maintenance_repair_request_form' => PropertyMaintenanceRepairRequestFormTemplate::class,
180 'corporate_event_sponsorship_application_form' => CorporateEventSponsorshipApplicationFormTemplate::class,
181 'startup_sponsorship_application_form' => StartupSponsorshipApplicationFormTemplate::class,
182 'media_influencer_sponsorship_application_form' => MediaInfluencerSponsorshipApplicationFormTemplate::class,
183 'business_vendor_onboarding_form' => BusinessVendorOnboardingFormTemplate::class,
184 'wholesale_supplier_application_form' => WholesaleSupplierApplicationFormTemplate::class,
185 'service_provider_partnership_application_form' => ServiceProviderPartnershipApplicationFormTemplate::class,
186 ];
187
188 /**
189 * Get the template map
190 *
191 * @return array<string, string>
192 */
193 public function getTemplateMap(): array
194 {
195 /**
196 * Allows modification of the template mapper.
197 *
198 * @since 0.1.0
199 *
200 * @param array<string, string> $templateMaper The current template mapper.
201 *
202 * @return array<string, string> The modified template mapper.
203 */
204 self::$templateMap = apply_filters(
205 'ivyforms/template/template_mapper',
206 self::$templateMap
207 );
208
209 return self::$templateMap;
210 }
211
212 /**
213 * Get template class by template ID
214 *
215 * @param string $templateId
216 * @return string|null Template class name or null if not found
217 */
218 public static function getTemplateClass(string $templateId): ?string
219 {
220 return (new TemplateMapper())->getTemplateMap()[$templateId] ?? null;
221 }
222
223 /**
224 * Get template data by template ID
225 *
226 * @param string $templateId
227 * @return array<string, mixed>|null Template data or null if not found
228 */
229 public static function getTemplate(string $templateId): ?array
230 {
231 $templateClass = self::getTemplateClass($templateId);
232
233 if (!$templateClass || !class_exists($templateClass)) {
234 return null;
235 }
236
237 return $templateClass::getTemplate();
238 }
239
240 /**
241 * Get all template IDs
242 *
243 * @return array<int, string>
244 */
245 public static function getAllTemplateIds(): array
246 {
247 return array_keys((new TemplateMapper())->getTemplateMap());
248 }
249
250 /**
251 * Check if template ID exists
252 *
253 * @param string $templateId
254 * @return bool
255 */
256 public static function hasTemplate(string $templateId): bool
257 {
258 return self::getTemplateClass($templateId) !== null;
259 }
260
261 /**
262 * Get all templates metadata (without form_data) for listing purposes
263 *
264 * Returns only: id, name, description, category, subcategory, is_pro, screenshot
265 * This avoids loading heavy form_data (fields, settings) for every template
266 * when only metadata is needed for browsing/searching.
267 *
268 * @return array<string, array<string, mixed>>
269 */
270 public static function getAllTemplateMetas(): array
271 {
272 $templates = [];
273
274 foreach ((new TemplateMapper())->getTemplateMap() as $templateId => $templateClass) {
275 // Skip BlankFormTemplate from public template list
276 if ($templateClass === BlankFormTemplate::class) {
277 continue;
278 }
279
280 if (class_exists($templateClass) && method_exists($templateClass, 'getTemplateMeta')) {
281 $templates[$templateId] = $templateClass::getTemplateMeta();
282 }
283 }
284
285 return $templates;
286 }
287 }
288