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

@@ -5,7 +5,7 @@
* This file contains functions to automatically generate a table of contents
* from post content headings (H2 and H3).
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -22,7 +22,7 @@ if (!defined('ABSPATH')) {
* @param string $content Post content
* @return array Array of headings with level, text, and ID
*/
function apus_extract_headings($content) {
function roi_extract_headings($content) {
if (empty($content)) {
return array();
}
@@ -37,7 +37,7 @@ function apus_extract_headings($content) {
$text = strip_tags($match[2]); // Remove any HTML tags inside heading
// Generate a clean ID from the heading text
$id = apus_generate_heading_id($text, $index);
$id = roi_generate_heading_id($text, $index);
$headings[] = array(
'level' => $level,
@@ -58,7 +58,7 @@ function apus_extract_headings($content) {
* @param int $index Index of the heading (for uniqueness)
* @return string Clean ID
*/
function apus_generate_heading_id($text, $index) {
function roi_generate_heading_id($text, $index) {
// Remove special characters and convert to lowercase
$id = sanitize_title($text);
@@ -75,30 +75,30 @@ function apus_generate_heading_id($text, $index) {
*
* Creates a nested list structure from the headings array.
*
* @param array $headings Array of headings from apus_extract_headings()
* @param array $headings Array of headings from roi_extract_headings()
* @return string HTML for the table of contents
*/
function apus_generate_toc($headings) {
function roi_generate_toc($headings) {
// Get minimum headings required from theme options
$min_headings = (int) apus_get_option('toc_min_headings', 2);
$min_headings = (int) roi_get_option('toc_min_headings', 2);
if (empty($headings) || count($headings) < $min_headings) {
return ''; // Don't show TOC if there are fewer headings than required
}
// Get custom TOC title from theme options
$toc_title = apus_get_toc_title();
$toc_title = roi_get_toc_title();
$toc_html = '<nav class="apus-toc" aria-label="' . esc_attr($toc_title) . '">';
$toc_html .= '<div class="apus-toc-header">';
$toc_html .= '<h2 class="apus-toc-title">' . esc_html($toc_title) . '</h2>';
$toc_html .= '<button class="apus-toc-toggle" aria-expanded="true" aria-controls="apus-toc-list">';
$toc_html = '<nav class="roi-toc" aria-label="' . esc_attr($toc_title) . '">';
$toc_html .= '<div class="roi-toc-header">';
$toc_html .= '<h2 class="roi-toc-title">' . esc_html($toc_title) . '</h2>';
$toc_html .= '<button class="roi-toc-toggle" aria-expanded="true" aria-controls="roi-toc-list">';
$toc_html .= '<span class="toggle-icon" aria-hidden="true"></span>';
$toc_html .= '<span class="screen-reader-text">' . esc_html__('Toggle Table of Contents', 'apus-theme') . '</span>';
$toc_html .= '<span class="screen-reader-text">' . esc_html__('Toggle Table of Contents', 'roi-theme') . '</span>';
$toc_html .= '</button>';
$toc_html .= '</div>';
$toc_html .= '<ol class="apus-toc-list" id="apus-toc-list">';
$toc_html .= '<ol class="roi-toc-list" id="roi-toc-list">';
$current_level = 2;
$open_sublists = 0;
@@ -111,7 +111,7 @@ function apus_generate_toc($headings) {
// Handle level changes
if ($level > $current_level) {
// Open nested list for H3
$toc_html .= '<ol class="apus-toc-sublist">';
$toc_html .= '<ol class="roi-toc-sublist">';
$open_sublists++;
} elseif ($level < $current_level && $open_sublists > 0) {
// Close nested list when going back to H2
@@ -122,8 +122,8 @@ function apus_generate_toc($headings) {
$toc_html .= '</li>';
}
$toc_html .= '<li class="apus-toc-item apus-toc-level-' . $level . '">';
$toc_html .= '<a href="#' . $id . '" class="apus-toc-link">' . $text . '</a>';
$toc_html .= '<li class="roi-toc-item roi-toc-level-' . $level . '">';
$toc_html .= '<a href="#' . $id . '" class="roi-toc-link">' . $text . '</a>';
$current_level = $level;
}
@@ -149,13 +149,13 @@ function apus_generate_toc($headings) {
* @param string $content Post content
* @return string Modified content with IDs added to headings
*/
function apus_add_heading_ids($content) {
function roi_add_heading_ids($content) {
if (empty($content)) {
return $content;
}
// Extract headings first to get consistent IDs
$headings = apus_extract_headings($content);
$headings = roi_extract_headings($content);
if (empty($headings)) {
return $content;
@@ -191,12 +191,12 @@ function apus_add_heading_ids($content) {
* @param string $content Post content
* @return string Modified content
*/
function apus_filter_content_add_heading_ids($content) {
function roi_filter_content_add_heading_ids($content) {
// Only apply to single posts
if (!is_single()) {
return $content;
}
return apus_add_heading_ids($content);
return roi_add_heading_ids($content);
}
add_filter('the_content', 'apus_filter_content_add_heading_ids', 10);
add_filter('the_content', 'roi_filter_content_add_heading_ids', 10);