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,77 @@
<?php
declare(strict_types=1);
namespace ROITheme\Admin\RelatedPost\Infrastructure\FieldMapping;
use ROITheme\Admin\Shared\Domain\Contracts\FieldMapperInterface;
/**
* Field Mapper para Related Post
*
* RESPONSABILIDAD:
* - Mapear field IDs del formulario a atributos de BD
* - Solo conoce sus propios campos (modularidad)
*
* NOTA: Este componente NO tenia mapeos en AdminAjaxHandler
* (era el unico componente roto - 35 campos no se guardaban)
*/
final class RelatedPostFieldMapper implements FieldMapperInterface
{
public function getComponentName(): string
{
return 'related-post';
}
public function getFieldMapping(): array
{
return [
// Visibility
'relatedPostEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
'relatedPostShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
'relatedPostShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],
'relatedPostShowOnPages' => ['group' => 'visibility', 'attribute' => 'show_on_pages'],
// Content
'relatedPostSectionTitle' => ['group' => 'content', 'attribute' => 'section_title'],
'relatedPostPerPage' => ['group' => 'content', 'attribute' => 'posts_per_page'],
'relatedPostOrderby' => ['group' => 'content', 'attribute' => 'orderby'],
'relatedPostOrder' => ['group' => 'content', 'attribute' => 'order'],
'relatedPostShowPagination' => ['group' => 'content', 'attribute' => 'show_pagination'],
// Layout
'relatedPostColsDesktop' => ['group' => 'layout', 'attribute' => 'columns_desktop'],
'relatedPostColsTablet' => ['group' => 'layout', 'attribute' => 'columns_tablet'],
'relatedPostColsMobile' => ['group' => 'layout', 'attribute' => 'columns_mobile'],
// Typography
'relatedPostSectionTitleSize' => ['group' => 'typography', 'attribute' => 'section_title_size'],
'relatedPostSectionTitleWeight' => ['group' => 'typography', 'attribute' => 'section_title_weight'],
'relatedPostCardTitleSize' => ['group' => 'typography', 'attribute' => 'card_title_size'],
'relatedPostCardTitleWeight' => ['group' => 'typography', 'attribute' => 'card_title_weight'],
// Colors
'relatedPostSectionTitleColor' => ['group' => 'colors', 'attribute' => 'section_title_color'],
'relatedPostCardBgColor' => ['group' => 'colors', 'attribute' => 'card_bg_color'],
'relatedPostCardTitleColor' => ['group' => 'colors', 'attribute' => 'card_title_color'],
'relatedPostCardHoverBgColor' => ['group' => 'colors', 'attribute' => 'card_hover_bg_color'],
'relatedPostPaginationBgColor' => ['group' => 'colors', 'attribute' => 'pagination_bg_color'],
'relatedPostPaginationTextColor' => ['group' => 'colors', 'attribute' => 'pagination_text_color'],
'relatedPostPaginationActiveBg' => ['group' => 'colors', 'attribute' => 'pagination_active_bg'],
'relatedPostPaginationActiveText' => ['group' => 'colors', 'attribute' => 'pagination_active_text'],
// Spacing
'relatedPostSectionMarginTop' => ['group' => 'spacing', 'attribute' => 'section_margin_top'],
'relatedPostSectionMarginBottom' => ['group' => 'spacing', 'attribute' => 'section_margin_bottom'],
'relatedPostTitleMarginBottom' => ['group' => 'spacing', 'attribute' => 'title_margin_bottom'],
'relatedPostGridGap' => ['group' => 'spacing', 'attribute' => 'grid_gap'],
'relatedPostCardPadding' => ['group' => 'spacing', 'attribute' => 'card_padding'],
'relatedPostPaginationMarginTop' => ['group' => 'spacing', 'attribute' => 'pagination_margin_top'],
// Visual Effects
'relatedPostCardBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'card_border_radius'],
'relatedPostCardShadow' => ['group' => 'visual_effects', 'attribute' => 'card_shadow'],
'relatedPostCardHoverShadow' => ['group' => 'visual_effects', 'attribute' => 'card_hover_shadow'],
'relatedPostCardTransition' => ['group' => 'visual_effects', 'attribute' => 'card_transition'],
];
}
}