Fase 1: Estructura Base y DI Container - Clean Architecture

COMPLETADO: Fase 1 de la migración a Clean Architecture + POO

## Estructura de Carpetas
- ✓ Estructura completa de 4 capas (Domain, Application, Infrastructure, Presentation)
- ✓ Carpetas de Use Cases (SaveComponent, GetComponent, DeleteComponent, SyncSchema)
- ✓ Estructura de tests (Unit, Integration, E2E)
- ✓ Carpetas de schemas y templates

## Composer y Autoloading
- ✓ PSR-4 autoloading configurado para ROITheme namespace
- ✓ Autoloader optimizado regenerado

## DI Container
- ✓ DIContainer implementado con patrón Singleton
- ✓ Métodos set(), get(), has() para gestión de servicios
- ✓ Getters específicos para ComponentRepository, ValidationService, CacheService
- ✓ Placeholders que serán implementados en Fase 5
- ✓ Prevención de clonación y deserialización

## Interfaces
- ✓ ComponentRepositoryInterface (Domain)
- ✓ ValidationServiceInterface (Application)
- ✓ CacheServiceInterface (Application)
- ✓ Component entity placeholder (Domain)

## Bootstrap
- ✓ functions.php actualizado con carga de Composer autoloader
- ✓ Inicialización del DIContainer
- ✓ Helper function roi_container() disponible globalmente

## Tests
- ✓ 10 tests unitarios para DIContainer (100% cobertura)
- ✓ Total: 13 tests unitarios, 28 assertions
- ✓ Suite de tests pasando correctamente

## Validación
- ✓ Script de validación automatizado (48/48 checks pasados)
- ✓ 100% de validaciones exitosas

La arquitectura base está lista para la Fase 2.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-11-17 13:48:24 -06:00
parent b782ebceee
commit de5fff4f5c
149 changed files with 3187 additions and 9554 deletions

View File

@@ -2,7 +2,7 @@
/**
* Font Options for Theme Customizer
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -14,81 +14,81 @@ if (!defined('ABSPATH')) {
/**
* Register font settings in the Customizer
*/
function apus_customize_register_fonts($wp_customize) {
function roi_customize_register_fonts($wp_customize) {
// Add Typography Section
$wp_customize->add_section('apus_typography', array(
'title' => __('Typography', 'apus-theme'),
'description' => __('Configure font settings for your site.', 'apus-theme'),
$wp_customize->add_section('roi_typography', array(
'title' => __('Typography', 'roi-theme'),
'description' => __('Configure font settings for your site.', 'roi-theme'),
'priority' => 30,
));
// Setting: Use Custom Fonts
$wp_customize->add_setting('apus_use_custom_fonts', array(
$wp_customize->add_setting('roi_use_custom_fonts', array(
'default' => false,
'sanitize_callback' => 'apus_sanitize_checkbox',
'sanitize_callback' => 'roi_sanitize_checkbox',
'transport' => 'refresh',
));
$wp_customize->add_control('apus_use_custom_fonts', array(
'label' => __('Use Custom Fonts', 'apus-theme'),
'description' => __('Enable custom fonts instead of system fonts. System fonts load faster and improve Core Web Vitals.', 'apus-theme'),
'section' => 'apus_typography',
$wp_customize->add_control('roi_use_custom_fonts', array(
'label' => __('Use Custom Fonts', 'roi-theme'),
'description' => __('Enable custom fonts instead of system fonts. System fonts load faster and improve Core Web Vitals.', 'roi-theme'),
'section' => 'roi_typography',
'type' => 'checkbox',
));
// Setting: Font Loading Strategy (only if custom fonts enabled)
$wp_customize->add_setting('apus_font_display', array(
$wp_customize->add_setting('roi_font_display', array(
'default' => 'swap',
'sanitize_callback' => 'apus_sanitize_select',
'sanitize_callback' => 'roi_sanitize_select',
'transport' => 'refresh',
));
$wp_customize->add_control('apus_font_display', array(
'label' => __('Font Display Strategy', 'apus-theme'),
'description' => __('Controls how fonts are displayed during loading. "swap" is recommended for best performance.', 'apus-theme'),
'section' => 'apus_typography',
$wp_customize->add_control('roi_font_display', array(
'label' => __('Font Display Strategy', 'roi-theme'),
'description' => __('Controls how fonts are displayed during loading. "swap" is recommended for best performance.', 'roi-theme'),
'section' => 'roi_typography',
'type' => 'select',
'choices' => array(
'auto' => __('Auto', 'apus-theme'),
'block' => __('Block', 'apus-theme'),
'swap' => __('Swap (Recommended)', 'apus-theme'),
'fallback' => __('Fallback', 'apus-theme'),
'optional' => __('Optional', 'apus-theme'),
'auto' => __('Auto', 'roi-theme'),
'block' => __('Block', 'roi-theme'),
'swap' => __('Swap (Recommended)', 'roi-theme'),
'fallback' => __('Fallback', 'roi-theme'),
'optional' => __('Optional', 'roi-theme'),
),
'active_callback' => 'apus_is_custom_fonts_enabled',
'active_callback' => 'roi_is_custom_fonts_enabled',
));
// Setting: Preload Fonts
$wp_customize->add_setting('apus_preload_fonts', array(
$wp_customize->add_setting('roi_preload_fonts', array(
'default' => true,
'sanitize_callback' => 'apus_sanitize_checkbox',
'sanitize_callback' => 'roi_sanitize_checkbox',
'transport' => 'refresh',
));
$wp_customize->add_control('apus_preload_fonts', array(
'label' => __('Preload Font Files', 'apus-theme'),
'description' => __('Preload critical font files for faster rendering. Recommended for better LCP scores.', 'apus-theme'),
'section' => 'apus_typography',
$wp_customize->add_control('roi_preload_fonts', array(
'label' => __('Preload Font Files', 'roi-theme'),
'description' => __('Preload critical font files for faster rendering. Recommended for better LCP scores.', 'roi-theme'),
'section' => 'roi_typography',
'type' => 'checkbox',
'active_callback' => 'apus_is_custom_fonts_enabled',
'active_callback' => 'roi_is_custom_fonts_enabled',
));
}
add_action('customize_register', 'apus_customize_register_fonts');
add_action('customize_register', 'roi_customize_register_fonts');
/**
* Check if custom fonts are enabled
*/
function apus_is_custom_fonts_enabled() {
return get_theme_mod('apus_use_custom_fonts', false);
function roi_is_custom_fonts_enabled() {
return get_theme_mod('roi_use_custom_fonts', false);
}
/**
* Add body class based on font settings
*/
function apus_font_body_class($classes) {
if (apus_is_custom_fonts_enabled()) {
function roi_font_body_class($classes) {
if (roi_is_custom_fonts_enabled()) {
$classes[] = 'use-custom-fonts';
} else {
$classes[] = 'use-system-fonts';
@@ -96,18 +96,18 @@ function apus_font_body_class($classes) {
return $classes;
}
add_filter('body_class', 'apus_font_body_class');
add_filter('body_class', 'roi_font_body_class');
/**
* Add preload links for custom fonts
*/
function apus_preload_custom_fonts() {
function roi_preload_custom_fonts() {
// Only preload if custom fonts are enabled and preload is enabled
if (!apus_is_custom_fonts_enabled()) {
if (!roi_is_custom_fonts_enabled()) {
return;
}
if (!get_theme_mod('apus_preload_fonts', true)) {
if (!get_theme_mod('roi_preload_fonts', true)) {
return;
}
@@ -120,26 +120,26 @@ function apus_preload_custom_fonts() {
*/
}
add_action('wp_head', 'apus_preload_custom_fonts', 1);
add_action('wp_head', 'roi_preload_custom_fonts', 1);
/**
* Output inline CSS for font display strategy
*/
function apus_output_font_display_css() {
if (!apus_is_custom_fonts_enabled()) {
function roi_output_font_display_css() {
if (!roi_is_custom_fonts_enabled()) {
return;
}
$font_display = get_theme_mod('apus_font_display', 'swap');
$font_display = get_theme_mod('roi_font_display', 'swap');
// This would be used if you have actual @font-face declarations
// For now, it's just a placeholder for future implementation
?>
<style id="apus-font-display-strategy">
<style id="roi-font-display-strategy">
/* Font display strategy: <?php echo esc_attr($font_display); ?> */
/* This would contain dynamic @font-face rules when custom fonts are added */
</style>
<?php
}
add_action('wp_head', 'apus_output_font_display_css', 5);
add_action('wp_head', 'roi_output_font_display_css', 5);