PROBLEMA: - El modal de contacto no se mostraba en producción (Linux) - Funcionaba en local (Windows) porque filesystem es case-insensitive - Carpeta: `WordPress` (con P mayúscula) - Namespaces: `Wordpress` (con p minúscula) SOLUCION: - Corregir todos los namespaces de `Wordpress` a `WordPress` - También corregir paths incorrectos `ROITheme\Component\...` a `ROITheme\Shared\...` ARCHIVOS CORREGIDOS (14): - functions.php - Admin/Infrastructure/Api/WordPress/AdminMenuRegistrar.php - Admin/Shared/Infrastructure/Api/WordPress/AdminAjaxHandler.php - Public/ContactForm/Infrastructure/Api/WordPress/ContactFormAjaxHandler.php - Public/Footer/Infrastructure/Api/WordPress/NewsletterAjaxHandler.php - Shared/Infrastructure/Api/WordPress/AjaxController.php - Shared/Infrastructure/Api/WordPress/MigrationCommand.php - Shared/Infrastructure/Di/DIContainer.php - Shared/Infrastructure/Persistence/WordPress/WordPressComponentRepository.php - Shared/Infrastructure/Persistence/WordPress/WordPressComponentSettingsRepository.php - Shared/Infrastructure/Persistence/WordPress/WordPressDefaultsRepository.php - Shared/Infrastructure/Services/CleanupService.php - Shared/Infrastructure/Services/SchemaSyncService.php - Shared/Infrastructure/Services/WordPressValidationService.php 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace ROITheme\Shared\Infrastructure\Services;
|
|
|
|
use ROITheme\Shared\Infrastructure\Persistence\WordPress\WordPressComponentRepository;
|
|
use ROITheme\Shared\Infrastructure\Persistence\WordPress\WordPressDefaultsRepository;
|
|
|
|
/**
|
|
* CleanupService - Limpieza de componentes obsoletos
|
|
*
|
|
* RESPONSABILIDAD: Eliminar componentes que ya no existen en schema
|
|
*
|
|
* @package ROITheme\Infrastructure\Services
|
|
*/
|
|
final class CleanupService
|
|
{
|
|
public function __construct(
|
|
private WordPressComponentRepository $componentRepository,
|
|
private WordPressDefaultsRepository $defaultsRepository
|
|
) {}
|
|
|
|
/**
|
|
* Eliminar componentes que no tienen schema
|
|
*
|
|
* @return array ['removed' => array]
|
|
*/
|
|
public function removeObsolete(): array
|
|
{
|
|
// Obtener todos los componentes actuales
|
|
$components = $this->componentRepository->findAll();
|
|
|
|
// Obtener schemas disponibles
|
|
$schemas = $this->defaultsRepository->findAll();
|
|
$validNames = array_keys($schemas);
|
|
|
|
$removed = [];
|
|
|
|
foreach ($components as $component) {
|
|
$name = $component->name()->value();
|
|
|
|
// Si el componente no tiene schema, es obsoleto
|
|
if (!in_array($name, $validNames)) {
|
|
$this->componentRepository->delete($name);
|
|
$removed[] = $name;
|
|
}
|
|
}
|
|
|
|
return ['removed' => $removed];
|
|
}
|
|
}
|