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 @@
*
* Helper functions for theme templates.
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
*
* @since 1.0.0
*/
function apus_posted_on() {
function roi_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
@@ -35,7 +35,7 @@ function apus_posted_on() {
$posted_on = sprintf(
/* translators: %s: post date. */
esc_html_x( 'Publicado el %s', 'post date', 'apus' ),
esc_html_x( 'Publicado el %s', 'post date', 'roi' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
@@ -47,10 +47,10 @@ function apus_posted_on() {
*
* @since 1.0.0
*/
function apus_posted_by() {
function roi_posted_by() {
$byline = sprintf(
/* translators: %s: post author. */
esc_html_x( 'por %s', 'post author', 'apus' ),
esc_html_x( 'por %s', 'post author', 'roi' ),
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
);
@@ -62,21 +62,21 @@ function apus_posted_by() {
*
* @since 1.0.0
*/
function apus_entry_footer() {
function roi_entry_footer() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'apus' ) );
$categories_list = get_the_category_list( esc_html__( ', ', 'roi' ) );
if ( $categories_list ) {
/* translators: 1: list of categories. */
printf( '<span class="cat-links">' . esc_html__( 'Categorías: %1$s', 'apus' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
printf( '<span class="cat-links">' . esc_html__( 'Categorías: %1$s', 'roi' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'apus' ) );
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'roi' ) );
if ( $tags_list ) {
/* translators: 1: list of tags. */
printf( '<span class="tags-links">' . esc_html__( 'Etiquetas: %1$s', 'apus' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
printf( '<span class="tags-links">' . esc_html__( 'Etiquetas: %1$s', 'roi' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
@@ -86,7 +86,7 @@ function apus_entry_footer() {
sprintf(
wp_kses(
/* translators: %s: post title */
__( 'Comentar<span class="screen-reader-text"> en %s</span>', 'apus' ),
__( 'Comentar<span class="screen-reader-text"> en %s</span>', 'roi' ),
array(
'span' => array(
'class' => array(),
@@ -103,7 +103,7 @@ function apus_entry_footer() {
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Editar <span class="screen-reader-text">%s</span>', 'apus' ),
__( 'Editar <span class="screen-reader-text">%s</span>', 'roi' ),
array(
'span' => array(
'class' => array(),
@@ -124,14 +124,14 @@ function apus_entry_footer() {
* @param int $length Default excerpt length.
* @return int Modified excerpt length.
*/
function apus_excerpt_length( $length ) {
function roi_excerpt_length( $length ) {
if ( is_admin() ) {
return $length;
}
return 40; // Change this to desired excerpt length.
}
add_filter( 'excerpt_length', 'apus_excerpt_length', 999 );
add_filter( 'excerpt_length', 'roi_excerpt_length', 999 );
/**
* Custom excerpt more string
@@ -140,14 +140,14 @@ add_filter( 'excerpt_length', 'apus_excerpt_length', 999 );
* @param string $more Default more string.
* @return string Modified more string.
*/
function apus_excerpt_more( $more ) {
function roi_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
}
return '&hellip;';
}
add_filter( 'excerpt_more', 'apus_excerpt_more' );
add_filter( 'excerpt_more', 'roi_excerpt_more' );
/**
* Get custom excerpt by character count
@@ -157,7 +157,7 @@ add_filter( 'excerpt_more', 'apus_excerpt_more' );
* @param string $more More string.
* @return string Custom excerpt.
*/
function apus_get_excerpt( $charlength = 200, $more = '...' ) {
function roi_get_excerpt( $charlength = 200, $more = '...' ) {
$excerpt = get_the_excerpt();
$charlength++;
@@ -185,7 +185,7 @@ function apus_get_excerpt( $charlength = 200, $more = '...' ) {
* @param string $size Image size.
* @return string|false Thumbnail URL or false if not found.
*/
function apus_get_post_thumbnail_url( $size = 'full' ) {
function roi_get_post_thumbnail_url( $size = 'full' ) {
if ( has_post_thumbnail() ) {
$thumb_id = get_post_thumbnail_id();
$thumb = wp_get_attachment_image_src( $thumb_id, $size );
@@ -204,14 +204,14 @@ function apus_get_post_thumbnail_url( $size = 'full' ) {
* @since 1.0.0
* @param array $args Breadcrumb arguments.
*/
function apus_breadcrumbs( $args = array() ) {
function roi_breadcrumbs( $args = array() ) {
// Default arguments.
$defaults = array(
'separator' => '<span class="separator">/</span>',
'home_label' => esc_html__( 'Inicio', 'apus' ),
'home_label' => esc_html__( 'Inicio', 'roi' ),
'show_home' => true,
'show_current' => true,
'before' => '<nav class="breadcrumbs" aria-label="' . esc_attr__( 'Breadcrumb', 'apus' ) . '"><ol class="breadcrumb-list">',
'before' => '<nav class="breadcrumbs" aria-label="' . esc_attr__( 'Breadcrumb', 'roi' ) . '"><ol class="breadcrumb-list">',
'after' => '</ol></nav>',
'link_before' => '<li class="breadcrumb-item">',
'link_after' => '</li>',
@@ -292,14 +292,14 @@ function apus_breadcrumbs( $args = array() ) {
echo $args['link_before'] . '<span class="current">' . esc_html( get_the_title() ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
} elseif ( is_search() ) {
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Resultados de búsqueda para: ', 'apus' ) . get_search_query() . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Resultados de búsqueda para: ', 'roi' ) . get_search_query() . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_tag() ) {
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Etiqueta: ', 'apus' ) . esc_html( single_tag_title( '', false ) ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Etiqueta: ', 'roi' ) . esc_html( single_tag_title( '', false ) ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_author() ) {
$author = get_queried_object();
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Autor: ', 'apus' ) . esc_html( $author->display_name ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Autor: ', 'roi' ) . esc_html( $author->display_name ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_day() ) {
echo $args['link_before'] . '<a href="' . esc_url( get_year_link( get_the_time( 'Y' ) ) ) . '">' . esc_html( get_the_time( 'Y' ) ) . '</a>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -317,7 +317,7 @@ function apus_breadcrumbs( $args = array() ) {
echo $args['link_before'] . '<span class="current">' . esc_html( get_the_time( 'Y' ) ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} elseif ( is_404() ) {
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Error 404', 'apus' ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['link_before'] . '<span class="current">' . esc_html__( 'Error 404', 'roi' ) . '</span>' . $args['link_after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo $args['after']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -330,7 +330,7 @@ function apus_breadcrumbs( $args = array() ) {
* @param array $classes Existing body classes.
* @return array Modified body classes.
*/
function apus_body_classes( $classes ) {
function roi_body_classes( $classes ) {
// Add class if sidebar is active.
if ( is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'has-sidebar';
@@ -351,7 +351,7 @@ function apus_body_classes( $classes ) {
return $classes;
}
add_filter( 'body_class', 'apus_body_classes' );
add_filter( 'body_class', 'roi_body_classes' );
/**
* Add custom post classes
@@ -360,7 +360,7 @@ add_filter( 'body_class', 'apus_body_classes' );
* @param array $classes Existing post classes.
* @return array Modified post classes.
*/
function apus_post_classes( $classes ) {
function roi_post_classes( $classes ) {
// Add class if post has thumbnail.
if ( has_post_thumbnail() ) {
$classes[] = 'has-post-thumbnail';
@@ -370,7 +370,7 @@ function apus_post_classes( $classes ) {
return $classes;
}
add_filter( 'post_class', 'apus_post_classes' );
add_filter( 'post_class', 'roi_post_classes' );
/**
* Sanitize SVG uploads
@@ -379,13 +379,13 @@ add_filter( 'post_class', 'apus_post_classes' );
* @param array $mimes Allowed mime types.
* @return array Modified mime types.
*/
function apus_add_svg_mime_types( $mimes ) {
function roi_add_svg_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'apus_add_svg_mime_types' );
add_filter( 'upload_mimes', 'roi_add_svg_mime_types' );
/**
* Pagination for archive pages
@@ -393,7 +393,7 @@ add_filter( 'upload_mimes', 'apus_add_svg_mime_types' );
* @since 1.0.0
* @param array $args Pagination arguments.
*/
function apus_pagination( $args = array() ) {
function roi_pagination( $args = array() ) {
global $wp_query;
// Don't print empty markup if there's only one page.
@@ -403,9 +403,9 @@ function apus_pagination( $args = array() ) {
$defaults = array(
'mid_size' => 2,
'prev_text' => esc_html__( '&larr; Anterior', 'apus' ),
'next_text' => esc_html__( 'Siguiente &rarr;', 'apus' ),
'screen_reader_text' => esc_html__( 'Navegación de entradas', 'apus' ),
'prev_text' => esc_html__( '&larr; Anterior', 'roi' ),
'next_text' => esc_html__( 'Siguiente &rarr;', 'roi' ),
'screen_reader_text' => esc_html__( 'Navegación de entradas', 'roi' ),
'type' => 'list',
'current' => max( 1, get_query_var( 'paged' ) ),
);
@@ -433,7 +433,7 @@ function apus_pagination( $args = array() ) {
* @param int $column Column number (1-4).
* @return string Bootstrap column classes.
*/
function apus_get_footer_column_class( $column = 1 ) {
function roi_get_footer_column_class( $column = 1 ) {
// Default configuration: Equal width columns (3 columns each on desktop).
// You can customize these classes per column as needed.
$column_classes = array(
@@ -451,7 +451,7 @@ function apus_get_footer_column_class( $column = 1 ) {
* @since 1.0.0
* @param array $column_classes Array of column classes.
*/
$column_classes = apply_filters( 'apus_footer_column_classes', $column_classes );
$column_classes = apply_filters( 'roi_footer_column_classes', $column_classes );
// Return the class for the specified column, or default to col-12 if not found.
return isset( $column_classes[ $column ] ) ? $column_classes[ $column ] : 'col-12';