Fase-01: Preparación del entorno y estructura inicial

- Verificación de entorno XAMPP (PHP 8.0.30, Composer 2.9.1, WP-CLI 2.12.0)
- Configuración de Composer con PSR-4 para 24 namespaces
- Configuración de PHPUnit con 140 tests preparados
- Configuración de PHPCS con WordPress Coding Standards
- Scripts de backup y rollback con mejoras de seguridad
- Estructura de contextos (admin/, public/, shared/)
- Schemas JSON para 11 componentes del sistema
- Código fuente inicial con arquitectura limpia en src/
- Documentación de procedimientos de emergencia

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-11-19 16:34:49 -06:00
parent 677fbd4368
commit 90de6df77c
86 changed files with 16098 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace ROITheme\Component\Application\UseCases\DeleteComponent;
/**
* DeleteComponentRequest - DTO para eliminar componente
*
* @package ROITheme\Application\UseCases\DeleteComponent
*/
final class DeleteComponentRequest
{
public function __construct(
private string $componentName
) {}
public function getComponentName(): string
{
return $this->componentName;
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace ROITheme\Component\Application\UseCases\DeleteComponent;
/**
* DeleteComponentResponse - DTO de respuesta para eliminación
*
* @package ROITheme\Application\UseCases\DeleteComponent
*/
final class DeleteComponentResponse
{
private function __construct(
private bool $success,
private ?string $message,
private ?string $error
) {}
public function isSuccess(): bool
{
return $this->success;
}
public function getMessage(): ?string
{
return $this->message;
}
public function getError(): ?string
{
return $this->error;
}
public static function success(string $message): self
{
return new self(true, $message, null);
}
public static function failure(string $error): self
{
return new self(false, null, $error);
}
public function toArray(): array
{
return [
'success' => $this->success,
'message' => $this->message,
'error' => $this->error
];
}
}

View File

@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace ROITheme\Component\Application\UseCases\DeleteComponent;
use ROITheme\Shared\Domain\ComponentRepositoryInterface;
use ROITheme\Component\Application\Contracts\CacheServiceInterface;
use ROITheme\Component\Domain\ValueObjects\ComponentName;
/**
* DeleteComponentUseCase - Eliminar componente
*
* RESPONSABILIDAD: Orquestar eliminación de componente
*
* FLUJO:
* 1. Verificar que existe
* 2. Eliminar de BD
* 3. Invalidar cache
* 4. Retornar confirmación
*
* @package ROITheme\Application\UseCases\DeleteComponent
*/
final class DeleteComponentUseCase
{
public function __construct(
private ComponentRepositoryInterface $repository,
private CacheServiceInterface $cache
) {}
public function execute(DeleteComponentRequest $request): DeleteComponentResponse
{
try {
$componentNameString = $request->getComponentName();
$componentName = new ComponentName($componentNameString);
// 1. Verificar que existe
$component = $this->repository->findByName($componentName);
if ($component === null) {
return DeleteComponentResponse::failure(
"Component '{$componentNameString}' not found"
);
}
// 2. Eliminar
$deleted = $this->repository->delete($componentName);
if (!$deleted) {
return DeleteComponentResponse::failure(
"Failed to delete component '{$componentNameString}'"
);
}
// 3. Invalidar cache
$this->cache->delete("component_{$componentNameString}");
// 4. Retornar éxito
return DeleteComponentResponse::success(
"Component '{$componentNameString}' deleted successfully"
);
} catch (\Exception $e) {
return DeleteComponentResponse::failure(
'Unexpected error: ' . $e->getMessage()
);
}
}
}