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

@@ -4,7 +4,7 @@
*
* Provides configurable related posts functionality with Bootstrap grid support.
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -19,7 +19,7 @@ if (!defined('ABSPATH')) {
* @param int $post_id The post ID to get related posts for
* @return WP_Query|false Query object with related posts or false if none found
*/
function apus_get_related_posts($post_id) {
function roi_get_related_posts($post_id) {
// Get post categories
$categories = wp_get_post_categories($post_id);
@@ -28,7 +28,7 @@ function apus_get_related_posts($post_id) {
}
// Get number of posts to display (default: 3)
$posts_per_page = get_option('apus_related_posts_count', 3);
$posts_per_page = get_option('roi_related_posts_count', 3);
// Query arguments
$args = array(
@@ -44,7 +44,7 @@ function apus_get_related_posts($post_id) {
);
// Allow filtering of query args
$args = apply_filters('apus_related_posts_args', $args, $post_id);
$args = apply_filters('roi_related_posts_args', $args, $post_id);
// Get related posts
$related_query = new WP_Query($args);
@@ -58,33 +58,33 @@ function apus_get_related_posts($post_id) {
* @param int|null $post_id Optional. Post ID. Default is current post.
* @return void
*/
function apus_display_related_posts($post_id = null) {
function roi_display_related_posts($post_id = null) {
// Get post ID
if (!$post_id) {
$post_id = get_the_ID();
}
// Check if related posts are enabled
$enabled = get_option('apus_related_posts_enabled', true);
$enabled = get_option('roi_related_posts_enabled', true);
if (!$enabled) {
return;
}
// Get related posts
$related_query = apus_get_related_posts($post_id);
$related_query = roi_get_related_posts($post_id);
if (!$related_query) {
return;
}
// Get configuration options
$title = get_option('apus_related_posts_title', __('Related Posts', 'apus-theme'));
$columns = get_option('apus_related_posts_columns', 3);
$show_excerpt = get_option('apus_related_posts_show_excerpt', true);
$show_date = get_option('apus_related_posts_show_date', true);
$show_category = get_option('apus_related_posts_show_category', true);
$excerpt_length = get_option('apus_related_posts_excerpt_length', 20);
$background_colors = get_option('apus_related_posts_bg_colors', array(
$title = get_option('roi_related_posts_title', __('Related Posts', 'roi-theme'));
$columns = get_option('roi_related_posts_columns', 3);
$show_excerpt = get_option('roi_related_posts_show_excerpt', true);
$show_date = get_option('roi_related_posts_show_date', true);
$show_category = get_option('roi_related_posts_show_category', true);
$excerpt_length = get_option('roi_related_posts_excerpt_length', 20);
$background_colors = get_option('roi_related_posts_bg_colors', array(
'#1a73e8', // Blue
'#e91e63', // Pink
'#4caf50', // Green
@@ -94,7 +94,7 @@ function apus_display_related_posts($post_id = null) {
));
// Calculate Bootstrap column class
$col_class = apus_get_column_class($columns);
$col_class = roi_get_column_class($columns);
// Start output
?>
@@ -126,7 +126,7 @@ function apus_display_related_posts($post_id = null) {
<!-- Card with Image -->
<div class="related-post-thumbnail">
<?php
the_post_thumbnail('apus-thumbnail', array(
the_post_thumbnail('roi-thumbnail', array(
'alt' => the_title_attribute(array('echo' => false)),
'loading' => 'lazy',
));
@@ -213,7 +213,7 @@ function apus_display_related_posts($post_id = null) {
* @param int $columns Number of columns (1-4)
* @return string Bootstrap column classes
*/
function apus_get_column_class($columns) {
function roi_get_column_class($columns) {
$columns = absint($columns);
switch ($columns) {
@@ -233,49 +233,49 @@ function apus_get_column_class($columns) {
/**
* Hook related posts display after post content
*/
function apus_hook_related_posts() {
function roi_hook_related_posts() {
if (is_single() && !is_attachment()) {
apus_display_related_posts();
roi_display_related_posts();
}
}
add_action('apus_after_post_content', 'apus_hook_related_posts');
add_action('roi_after_post_content', 'roi_hook_related_posts');
/**
* Enqueue related posts styles
*/
function apus_enqueue_related_posts_styles() {
function roi_enqueue_related_posts_styles() {
if (is_single() && !is_attachment()) {
$enabled = get_option('apus_related_posts_enabled', true);
$enabled = get_option('roi_related_posts_enabled', true);
if ($enabled) {
wp_enqueue_style(
'apus-related-posts',
'roirelated-posts',
get_template_directory_uri() . '/assets/css/related-posts.css',
array('apus-bootstrap'),
APUS_VERSION,
array('roibootstrap'),
ROI_VERSION,
'all'
);
}
}
}
add_action('wp_enqueue_scripts', 'apus_enqueue_related_posts_styles');
add_action('wp_enqueue_scripts', 'roi_enqueue_related_posts_styles');
/**
* Register related posts settings
* These can be configured via theme options or customizer
*/
function apus_related_posts_default_options() {
function roi_related_posts_default_options() {
// Set default options if they don't exist
$defaults = array(
'apus_related_posts_enabled' => true,
'apus_related_posts_title' => __('Related Posts', 'apus-theme'),
'apus_related_posts_count' => 3,
'apus_related_posts_columns' => 3,
'apus_related_posts_show_excerpt' => true,
'apus_related_posts_excerpt_length' => 20,
'apus_related_posts_show_date' => true,
'apus_related_posts_show_category' => true,
'apus_related_posts_bg_colors' => array(
'roi_related_posts_enabled' => true,
'roi_related_posts_title' => __('Related Posts', 'roi-theme'),
'roi_related_posts_count' => 3,
'roi_related_posts_columns' => 3,
'roi_related_posts_show_excerpt' => true,
'roi_related_posts_excerpt_length' => 20,
'roi_related_posts_show_date' => true,
'roi_related_posts_show_category' => true,
'roi_related_posts_bg_colors' => array(
'#1a73e8', // Blue
'#e91e63', // Pink
'#4caf50', // Green
@@ -291,4 +291,4 @@ function apus_related_posts_default_options() {
}
}
}
add_action('after_setup_theme', 'apus_related_posts_default_options');
add_action('after_setup_theme', 'roi_related_posts_default_options');