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

@@ -1,8 +1,8 @@
<?php
/**
* Apus Theme Functions and Definitions
* ROI Theme Functions and Definitions
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -11,17 +11,51 @@ if (!defined('ABSPATH')) {
exit;
}
/**
* ========================================================================
* BOOTSTRAP CLEAN ARCHITECTURE (Fase 1)
* ========================================================================
*
* Carga el autoloader de Composer y el DI Container.
* Esta sección inicializa la arquitectura limpia del tema.
*/
// Load Composer autoloader
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}
// Initialize DI Container
use ROITheme\Infrastructure\DI\DIContainer;
/**
* Get DI Container instance
*
* Helper function to access the DI Container throughout the theme.
*
* @return DIContainer
*/
function roi_container(): DIContainer {
return DIContainer::getInstance();
}
/**
* ========================================================================
* END BOOTSTRAP
* ========================================================================
*/
/**
* Theme Version
*/
define('APUS_VERSION', '1.0.19');
define('ROI_VERSION', '1.0.19');
/**
* Theme Setup
*/
function apus_theme_setup() {
function roi_theme_setup() {
// Make theme available for translation
load_theme_textdomain('apus-theme', get_template_directory() . '/languages');
load_theme_textdomain('roi-theme', get_template_directory() . '/languages');
// Let WordPress manage the document title
add_theme_support('title-tag');
@@ -30,11 +64,11 @@ function apus_theme_setup() {
add_theme_support('post-thumbnails');
// Add image sizes
add_image_size('apus-thumbnail', 400, 300, true);
add_image_size('apus-medium', 800, 600, true);
add_image_size('apus-large', 1200, 900, true);
add_image_size('apus-featured-large', 1200, 600, true);
add_image_size('apus-featured-medium', 800, 400, true);
add_image_size('roi-thumbnail', 400, 300, true);
add_image_size('roi-medium', 800, 600, true);
add_image_size('roi-large', 1200, 900, true);
add_image_size('roi-featured-large', 1200, 600, true);
add_image_size('roi-featured-medium', 800, 400, true);
// Switch default core markup to output valid HTML5
add_theme_support('html5', array(
@@ -51,26 +85,26 @@ function apus_theme_setup() {
// Register navigation menus
register_nav_menus(array(
'primary' => __('Primary Menu', 'apus-theme'),
'footer' => __('Footer Menu', 'apus-theme'),
'primary' => __('Primary Menu', 'roi-theme'),
'footer' => __('Footer Menu', 'roi-theme'),
));
}
add_action('after_setup_theme', 'apus_theme_setup');
add_action('after_setup_theme', 'roi_theme_setup');
/**
* Set the content width in pixels
*/
function apus_content_width() {
$GLOBALS['content_width'] = apply_filters('apus_content_width', 1200);
function roi_content_width() {
$GLOBALS['content_width'] = apply_filters('roi_content_width', 1200);
}
add_action('after_setup_theme', 'apus_content_width', 0);
add_action('after_setup_theme', 'roi_content_width', 0);
/**
* ELIMINADO: apus_enqueue_scripts()
* ELIMINADO: roi_enqueue_scripts()
*
* Esta función estaba duplicando la carga de CSS.
* El sistema modular en inc/enqueue-scripts.php ya carga style.css como 'apus-main-style' (prioridad 5).
* Esta función duplicada lo cargaba otra vez como 'apus-theme-style' (prioridad 10).
* El sistema modular en inc/enqueue-scripts.php ya carga style.css como 'roi-main-style' (prioridad 5).
* Esta función duplicada lo cargaba otra vez como 'roi-theme-style' (prioridad 10).
*
* Fecha eliminación: 2025-01-08
* Issue: #128 - Footer Contact Form
@@ -79,12 +113,12 @@ add_action('after_setup_theme', 'apus_content_width', 0);
/**
* Register Widget Areas
*/
function apus_register_widget_areas() {
function roi_register_widget_areas() {
// Primary Sidebar
register_sidebar(array(
'name' => __('Primary Sidebar', 'apus-theme'),
'name' => __('Primary Sidebar', 'roi-theme'),
'id' => 'sidebar-1',
'description' => __('Main sidebar widget area', 'apus-theme'),
'description' => __('Main sidebar widget area', 'roi-theme'),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
@@ -93,9 +127,9 @@ function apus_register_widget_areas() {
// Footer Contact Form (Issue #37) - ARRIBA de los 4 widgets
register_sidebar(array(
'name' => __('Footer Contact Form', 'apus-theme'),
'name' => __('Footer Contact Form', 'roi-theme'),
'id' => 'footer-contact',
'description' => __('Área de contacto arriba de los 4 widgets del footer', 'apus-theme'),
'description' => __('Área de contacto arriba de los 4 widgets del footer', 'roi-theme'),
'before_widget' => '<section id="%1$s" class="footer-contact-widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
@@ -105,9 +139,9 @@ function apus_register_widget_areas() {
// Footer Widget Areas
for ($i = 1; $i <= 4; $i++) {
register_sidebar(array(
'name' => sprintf(__('Footer Column %d', 'apus-theme'), $i),
'name' => sprintf(__('Footer Column %d', 'roi-theme'), $i),
'id' => 'footer-' . $i,
'description' => sprintf(__('Footer widget area %d', 'apus-theme'), $i),
'description' => sprintf(__('Footer widget area %d', 'roi-theme'), $i),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
@@ -115,26 +149,26 @@ function apus_register_widget_areas() {
));
}
}
add_action('widgets_init', 'apus_register_widget_areas');
add_action('widgets_init', 'roi_register_widget_areas');
/**
* Configure locale and date format
*/
function apus_configure_locale() {
function roi_configure_locale() {
// Set locale to es_MX
add_filter('locale', function($locale) {
return 'es_MX';
});
}
add_action('after_setup_theme', 'apus_configure_locale');
add_action('after_setup_theme', 'roi_configure_locale');
/**
* Custom date format
*/
function apus_custom_date_format($format) {
function roi_custom_date_format($format) {
return 'd/m/Y'; // Format: day/month/year
}
add_filter('date_format', 'apus_custom_date_format');
add_filter('date_format', 'roi_custom_date_format');
/**
* Include modular files
@@ -150,17 +184,13 @@ if (file_exists(get_template_directory() . '/inc/theme-options-helpers.php')) {
}
// Admin Options API (Theme Options)
// DESACTIVADO: Ahora se usa el nuevo Admin Panel (admin/init.php se carga más abajo)
/*
// Cargar solo options-api.php para funciones auxiliares como roi_get_default_options()
// theme-options.php está desactivado porque el menú se registra en admin/includes/class-admin-menu.php
if (is_admin()) {
if (file_exists(get_template_directory() . '/admin/theme-options/options-api.php')) {
require_once get_template_directory() . '/admin/theme-options/options-api.php';
}
if (file_exists(get_template_directory() . '/admin/theme-options/theme-options.php')) {
require_once get_template_directory() . '/admin/theme-options/theme-options.php';
}
}
*/
// Bootstrap Nav Walker
if (file_exists(get_template_directory() . '/inc/nav-walker.php')) {