refactor(admin): Migrate AdminAjaxHandler to Clean Architecture

- Move AdminAjaxHandler to Admin/Shared/Infrastructure/Api/Wordpress/
- Create FieldMapperInterface for decentralized field mapping
- Create FieldMapperRegistry for module discovery
- Create FieldMapperProvider for auto-registration of 12 mappers
- Add FieldMappers for all components:
  - ContactFormFieldMapper (46 fields)
  - CtaBoxSidebarFieldMapper (32 fields)
  - CtaLetsTalkFieldMapper
  - CtaPostFieldMapper
  - FeaturedImageFieldMapper (15 fields)
  - FooterFieldMapper (31 fields)
  - HeroFieldMapper
  - NavbarFieldMapper
  - RelatedPostFieldMapper (34 fields)
  - SocialShareFieldMapper
  - TableOfContentsFieldMapper
  - TopNotificationBarFieldMapper (17 fields)
- Update functions.php bootstrap with FieldMapperProvider
- AdminAjaxHandler reduced from ~700 to 145 lines
- Follows SRP, OCP, DIP principles

BACKUP BEFORE: Removing CTA A/B Testing legacy system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-11-26 20:18:55 -06:00
parent 1a4d9d8c08
commit 4f11c2c312
19 changed files with 1199 additions and 703 deletions

View File

@@ -0,0 +1,98 @@
<?php
declare(strict_types=1);
namespace ROITheme\Admin\ContactForm\Infrastructure\FieldMapping;
use ROITheme\Admin\Shared\Domain\Contracts\FieldMapperInterface;
/**
* Field Mapper para Contact Form
*
* RESPONSABILIDAD:
* - Mapear field IDs del formulario a atributos de BD
* - Solo conoce sus propios campos (modularidad)
*/
final class ContactFormFieldMapper implements FieldMapperInterface
{
public function getComponentName(): string
{
return 'contact-form';
}
public function getFieldMapping(): array
{
return [
// Visibility
'contactFormEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
'contactFormShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
'contactFormShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],
'contactFormShowOnPages' => ['group' => 'visibility', 'attribute' => 'show_on_pages'],
// Content
'contactFormSectionTitle' => ['group' => 'content', 'attribute' => 'section_title'],
'contactFormSectionDescription' => ['group' => 'content', 'attribute' => 'section_description'],
'contactFormSubmitButtonText' => ['group' => 'content', 'attribute' => 'submit_button_text'],
'contactFormSubmitButtonIcon' => ['group' => 'content', 'attribute' => 'submit_button_icon'],
// Contact Info
'contactFormShowContactInfo' => ['group' => 'contact_info', 'attribute' => 'show_contact_info'],
'contactFormPhoneLabel' => ['group' => 'contact_info', 'attribute' => 'phone_label'],
'contactFormPhoneValue' => ['group' => 'contact_info', 'attribute' => 'phone_value'],
'contactFormEmailLabel' => ['group' => 'contact_info', 'attribute' => 'email_label'],
'contactFormEmailValue' => ['group' => 'contact_info', 'attribute' => 'email_value'],
'contactFormLocationLabel' => ['group' => 'contact_info', 'attribute' => 'location_label'],
'contactFormLocationValue' => ['group' => 'contact_info', 'attribute' => 'location_value'],
// Form Labels
'contactFormFullnamePlaceholder' => ['group' => 'form_labels', 'attribute' => 'fullname_placeholder'],
'contactFormCompanyPlaceholder' => ['group' => 'form_labels', 'attribute' => 'company_placeholder'],
'contactFormWhatsappPlaceholder' => ['group' => 'form_labels', 'attribute' => 'whatsapp_placeholder'],
'contactFormEmailPlaceholder' => ['group' => 'form_labels', 'attribute' => 'email_placeholder'],
'contactFormMessagePlaceholder' => ['group' => 'form_labels', 'attribute' => 'message_placeholder'],
// Integration
'contactFormWebhookUrl' => ['group' => 'integration', 'attribute' => 'webhook_url'],
'contactFormWebhookMethod' => ['group' => 'integration', 'attribute' => 'webhook_method'],
'contactFormIncludePageUrl' => ['group' => 'integration', 'attribute' => 'include_page_url'],
'contactFormIncludeTimestamp' => ['group' => 'integration', 'attribute' => 'include_timestamp'],
// Messages
'contactFormSuccessMessage' => ['group' => 'messages', 'attribute' => 'success_message'],
'contactFormErrorMessage' => ['group' => 'messages', 'attribute' => 'error_message'],
'contactFormSendingMessage' => ['group' => 'messages', 'attribute' => 'sending_message'],
'contactFormValidationRequired' => ['group' => 'messages', 'attribute' => 'validation_required'],
'contactFormValidationEmail' => ['group' => 'messages', 'attribute' => 'validation_email'],
// Colors
'contactFormSectionBgColor' => ['group' => 'colors', 'attribute' => 'section_bg_color'],
'contactFormTitleColor' => ['group' => 'colors', 'attribute' => 'title_color'],
'contactFormDescriptionColor' => ['group' => 'colors', 'attribute' => 'description_color'],
'contactFormIconColor' => ['group' => 'colors', 'attribute' => 'icon_color'],
'contactFormInfoLabelColor' => ['group' => 'colors', 'attribute' => 'info_label_color'],
'contactFormInfoValueColor' => ['group' => 'colors', 'attribute' => 'info_value_color'],
'contactFormInputBorderColor' => ['group' => 'colors', 'attribute' => 'input_border_color'],
'contactFormInputFocusBorder' => ['group' => 'colors', 'attribute' => 'input_focus_border'],
'contactFormButtonBgColor' => ['group' => 'colors', 'attribute' => 'button_bg_color'],
'contactFormButtonTextColor' => ['group' => 'colors', 'attribute' => 'button_text_color'],
'contactFormButtonHoverBg' => ['group' => 'colors', 'attribute' => 'button_hover_bg'],
'contactFormSuccessBgColor' => ['group' => 'colors', 'attribute' => 'success_bg_color'],
'contactFormSuccessTextColor' => ['group' => 'colors', 'attribute' => 'success_text_color'],
'contactFormErrorBgColor' => ['group' => 'colors', 'attribute' => 'error_bg_color'],
'contactFormErrorTextColor' => ['group' => 'colors', 'attribute' => 'error_text_color'],
// Spacing
'contactFormSectionPaddingY' => ['group' => 'spacing', 'attribute' => 'section_padding_y'],
'contactFormSectionMarginTop' => ['group' => 'spacing', 'attribute' => 'section_margin_top'],
'contactFormTitleMarginBottom' => ['group' => 'spacing', 'attribute' => 'title_margin_bottom'],
'contactFormDescriptionMarginBottom' => ['group' => 'spacing', 'attribute' => 'description_margin_bottom'],
'contactFormFormGap' => ['group' => 'spacing', 'attribute' => 'form_gap'],
// Visual Effects
'contactFormInputBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'input_border_radius'],
'contactFormButtonBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'button_border_radius'],
'contactFormButtonPadding' => ['group' => 'visual_effects', 'attribute' => 'button_padding'],
'contactFormTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
'contactFormTextareaRows' => ['group' => 'visual_effects', 'attribute' => 'textarea_rows'],
];
}
}