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 @@
/**
* Theme Options Settings API
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -14,65 +14,65 @@ if (!defined('ABSPATH')) {
/**
* Register all theme settings
*/
function apus_register_settings() {
function roi_register_settings() {
// Register main options group
register_setting(
'apus_theme_options_group',
'apus_theme_options',
'roi_theme_options_group',
'roi_theme_options',
array(
'sanitize_callback' => 'apus_sanitize_options',
'default' => apus_get_default_options(),
'sanitize_callback' => 'roi_sanitize_options',
'default' => roi_get_default_options(),
)
);
// General Settings Section
add_settings_section(
'apus_general_section',
__('General Settings', 'apus-theme'),
'apus_general_section_callback',
'apus-theme-options'
'roi_general_section',
__('General Settings', 'roi-theme'),
'roi_general_section_callback',
'roitheme-options'
);
// Content Settings Section
add_settings_section(
'apus_content_section',
__('Content Settings', 'apus-theme'),
'apus_content_section_callback',
'apus-theme-options'
'roi_content_section',
__('Content Settings', 'roi-theme'),
'roi_content_section_callback',
'roitheme-options'
);
// Performance Settings Section
add_settings_section(
'apus_performance_section',
__('Performance Settings', 'apus-theme'),
'apus_performance_section_callback',
'apus-theme-options'
'roi_performance_section',
__('Performance Settings', 'roi-theme'),
'roi_performance_section_callback',
'roitheme-options'
);
// Related Posts Settings Section
add_settings_section(
'apus_related_posts_section',
__('Related Posts Settings', 'apus-theme'),
'apus_related_posts_section_callback',
'apus-theme-options'
'roi_related_posts_section',
__('Related Posts Settings', 'roi-theme'),
'roi_related_posts_section_callback',
'roitheme-options'
);
// Social Share Settings Section
add_settings_section(
'apus_social_share_section',
__('Social Share Buttons', 'apus-theme'),
'apus_social_share_section_callback',
'apus-theme-options'
'roi_social_share_section',
__('Social Share Buttons', 'roi-theme'),
'roi_social_share_section_callback',
'roitheme-options'
);
}
add_action('admin_init', 'apus_register_settings');
add_action('admin_init', 'roi_register_settings');
/**
* Get default options
*
* @return array
*/
function apus_get_default_options() {
function roi_get_default_options() {
return array(
// General
'site_logo' => 0,
@@ -81,7 +81,7 @@ function apus_get_default_options() {
'breadcrumb_separator' => '>',
'date_format' => 'd/m/Y',
'time_format' => 'H:i',
'copyright_text' => sprintf(__('&copy; %s %s. All rights reserved.', 'apus-theme'), date('Y'), get_bloginfo('name')),
'copyright_text' => sprintf(__('&copy; %s %s. All rights reserved.', 'roi-theme'), date('Y'), get_bloginfo('name')),
'social_facebook' => '',
'social_twitter' => '',
'social_instagram' => '',
@@ -115,12 +115,12 @@ function apus_get_default_options() {
'enable_related_posts' => true,
'related_posts_count' => 3,
'related_posts_taxonomy' => 'category',
'related_posts_title' => __('Related Posts', 'apus-theme'),
'related_posts_title' => __('Related Posts', 'roi-theme'),
'related_posts_columns' => 3,
// Social Share Buttons
'apus_enable_share_buttons' => '1',
'apus_share_text' => __('Compartir:', 'apus-theme'),
'roi_enable_share_buttons' => '1',
'roi_share_text' => __('Compartir:', 'roi-theme'),
// Advanced
'custom_css' => '',
@@ -132,24 +132,24 @@ function apus_get_default_options() {
/**
* Section Callbacks
*/
function apus_general_section_callback() {
echo '<p>' . __('Configure general theme settings including logo, branding, and social media.', 'apus-theme') . '</p>';
function roi_general_section_callback() {
echo '<p>' . __('Configure general theme settings including logo, branding, and social media.', 'roi-theme') . '</p>';
}
function apus_content_section_callback() {
echo '<p>' . __('Configure content display settings for posts, pages, and archives.', 'apus-theme') . '</p>';
function roi_content_section_callback() {
echo '<p>' . __('Configure content display settings for posts, pages, and archives.', 'roi-theme') . '</p>';
}
function apus_performance_section_callback() {
echo '<p>' . __('Optimize your site performance with these settings.', 'apus-theme') . '</p>';
function roi_performance_section_callback() {
echo '<p>' . __('Optimize your site performance with these settings.', 'roi-theme') . '</p>';
}
function apus_related_posts_section_callback() {
echo '<p>' . __('Configure related posts display on single post pages.', 'apus-theme') . '</p>';
function roi_related_posts_section_callback() {
echo '<p>' . __('Configure related posts display on single post pages.', 'roi-theme') . '</p>';
}
function apus_social_share_section_callback() {
echo '<p>' . __('Configure social share buttons display on single post pages.', 'apus-theme') . '</p>';
function roi_social_share_section_callback() {
echo '<p>' . __('Configure social share buttons display on single post pages.', 'roi-theme') . '</p>';
}
/**
@@ -158,7 +158,7 @@ function apus_social_share_section_callback() {
* @param array $input The input array
* @return array The sanitized array
*/
function apus_sanitize_options($input) {
function roi_sanitize_options($input) {
$sanitized = array();
if (!is_array($input)) {
@@ -208,17 +208,17 @@ function apus_sanitize_options($input) {
$sanitized['enable_related_posts'] = isset($input['enable_related_posts']) ? (bool) $input['enable_related_posts'] : false;
$sanitized['related_posts_count'] = isset($input['related_posts_count']) ? absint($input['related_posts_count']) : 3;
$sanitized['related_posts_taxonomy'] = isset($input['related_posts_taxonomy']) ? sanitize_text_field($input['related_posts_taxonomy']) : 'category';
$sanitized['related_posts_title'] = isset($input['related_posts_title']) ? sanitize_text_field($input['related_posts_title']) : __('Related Posts', 'apus-theme');
$sanitized['related_posts_title'] = isset($input['related_posts_title']) ? sanitize_text_field($input['related_posts_title']) : __('Related Posts', 'roi-theme');
$sanitized['related_posts_columns'] = isset($input['related_posts_columns']) ? absint($input['related_posts_columns']) : 3;
// Social Share Buttons
$sanitized['apus_enable_share_buttons'] = isset($input['apus_enable_share_buttons']) ? sanitize_text_field($input['apus_enable_share_buttons']) : '1';
$sanitized['apus_share_text'] = isset($input['apus_share_text']) ? sanitize_text_field($input['apus_share_text']) : __('Compartir:', 'apus-theme');
$sanitized['roi_enable_share_buttons'] = isset($input['roi_enable_share_buttons']) ? sanitize_text_field($input['roi_enable_share_buttons']) : '1';
$sanitized['roi_share_text'] = isset($input['roi_share_text']) ? sanitize_text_field($input['roi_share_text']) : __('Compartir:', 'roi-theme');
// Advanced Settings
$sanitized['custom_css'] = isset($input['custom_css']) ? apus_sanitize_css($input['custom_css']) : '';
$sanitized['custom_js_header'] = isset($input['custom_js_header']) ? apus_sanitize_js($input['custom_js_header']) : '';
$sanitized['custom_js_footer'] = isset($input['custom_js_footer']) ? apus_sanitize_js($input['custom_js_footer']) : '';
$sanitized['custom_css'] = isset($input['custom_css']) ? roi_sanitize_css($input['custom_css']) : '';
$sanitized['custom_js_header'] = isset($input['custom_js_header']) ? roi_sanitize_js($input['custom_js_header']) : '';
$sanitized['custom_js_footer'] = isset($input['custom_js_footer']) ? roi_sanitize_js($input['custom_js_footer']) : '';
return $sanitized;
}
@@ -226,12 +226,12 @@ function apus_sanitize_options($input) {
/**
* NOTE: All sanitization functions have been moved to inc/sanitize-functions.php
* to avoid function redeclaration errors. This includes:
* - apus_sanitize_css()
* - apus_sanitize_js()
* - apus_sanitize_integer()
* - apus_sanitize_text()
* - apus_sanitize_url()
* - apus_sanitize_html()
* - apus_sanitize_checkbox()
* - apus_sanitize_select()
* - roi_sanitize_css()
* - roi_sanitize_js()
* - roi_sanitize_integer()
* - roi_sanitize_text()
* - roi_sanitize_url()
* - roi_sanitize_html()
* - roi_sanitize_checkbox()
* - roi_sanitize_select()
*/