fix(structure): Correct case-sensitivity for Linux compatibility

Rename folders to match PHP PSR-4 autoloading conventions:
- schemas → Schemas
- shared → Shared
- Wordpress → WordPress (in all locations)

Fixes deployment issues on Linux servers where filesystem is case-sensitive.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-11-26 22:53:34 -06:00
parent a2548ab5c2
commit 90863cd8f5
92 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace ROITheme\Shared\Application\UseCases\GetComponent;
/**
* GetComponentRequest - DTO de entrada para obtener componente
*
* RESPONSABILIDAD: Encapsular el nombre del componente a obtener
*
* USO:
* ```php
* $request = new GetComponentRequest('top_bar');
* ```
*
* @package ROITheme\Shared\Application\UseCases\GetComponent
*/
final readonly class GetComponentRequest
{
/**
* @param string $componentName Nombre del componente a obtener
*/
public function __construct(
private string $componentName
) {}
/**
* Obtener nombre del componente
*
* @return string
*/
public function getComponentName(): string
{
return $this->componentName;
}
/**
* Factory method: Crear desde string
*
* @param string $componentName
* @return self
*/
public static function fromString(string $componentName): self
{
return new self($componentName);
}
}

View File

@@ -0,0 +1,109 @@
<?php
declare(strict_types=1);
namespace ROITheme\Shared\Application\UseCases\GetComponent;
/**
* GetComponentResponse - DTO de salida para obtener componente
*
* RESPONSABILIDAD: Encapsular resultado de obtener un componente
*
* PATRÓN: Success/Failure
* - Éxito: success=true, data contiene el componente
* - Fallo: success=false, error contiene mensaje de error
*
* USO:
* ```php
* $response = GetComponentResponse::success($componentData);
* if ($response->isSuccess()) {
* $data = $response->getData();
* }
* ```
*
* @package ROITheme\Shared\Application\UseCases\GetComponent
*/
final readonly class GetComponentResponse
{
/**
* Constructor privado - usar factory methods
*
* @param bool $success Indica si la operación fue exitosa
* @param mixed $data Datos del componente (solo si success=true)
* @param string|null $error Mensaje de error (solo si success=false)
*/
private function __construct(
private bool $success,
private mixed $data,
private ?string $error
) {}
/**
* Verificar si la operación fue exitosa
*
* @return bool
*/
public function isSuccess(): bool
{
return $this->success;
}
/**
* Obtener datos del componente
*
* Solo válido si isSuccess() === true
*
* @return mixed
*/
public function getData(): mixed
{
return $this->data;
}
/**
* Obtener mensaje de error
*
* Solo válido si isSuccess() === false
*
* @return string|null
*/
public function getError(): ?string
{
return $this->error;
}
/**
* Factory method: Crear respuesta exitosa
*
* @param mixed $data Datos del componente
* @return self
*/
public static function success(mixed $data): self
{
return new self(true, $data, null);
}
/**
* Factory method: Crear respuesta de fallo
*
* @param string $error Mensaje de error
* @return self
*/
public static function failure(string $error): self
{
return new self(false, null, $error);
}
/**
* Convertir a array para serialización
*
* @return array
*/
public function toArray(): array
{
return [
'success' => $this->success,
'data' => $this->data,
'error' => $this->error
];
}
}

View File

@@ -0,0 +1,105 @@
<?php
declare(strict_types=1);
namespace ROITheme\Shared\Application\UseCases\GetComponent;
use ROITheme\Shared\Domain\Contracts\ComponentRepositoryInterface;
use ROITheme\Shared\Domain\Contracts\CacheServiceInterface;
use ROITheme\Shared\Domain\Exceptions\ComponentNotFoundException;
use ROITheme\Shared\Domain\ValueObjects\ComponentName;
/**
* GetComponentUseCase - Caso de Uso para obtener componente
*
* RESPONSABILIDAD: Orquestar la lógica de obtener un componente
*
* FLUJO:
* 1. Intentar obtener del cache
* 2. Si no está en cache, obtener del repositorio
* 3. Si no existe, lanzar excepción
* 4. Guardar en cache
* 5. Retornar respuesta
*
* OPTIMIZACIÓN:
* - Cache-first strategy para reducir queries a BD
* - TTL de 1 hora en cache
*
* USO:
* ```php
* $useCase = new GetComponentUseCase($repository, $cache);
* $request = new GetComponentRequest('top_bar');
* $response = $useCase->execute($request);
* ```
*
* @package ROITheme\Shared\Application\UseCases\GetComponent
*/
final class GetComponentUseCase
{
private const CACHE_TTL = 3600; // 1 hora
/**
* @param ComponentRepositoryInterface $repository Repositorio de componentes
* @param CacheServiceInterface $cache Servicio de cache
*/
public function __construct(
private ComponentRepositoryInterface $repository,
private CacheServiceInterface $cache
) {}
/**
* Ejecutar Use Case
*
* @param GetComponentRequest $request Datos de entrada
* @return GetComponentResponse Respuesta (éxito o fallo)
*/
public function execute(GetComponentRequest $request): GetComponentResponse
{
try {
$componentNameString = $request->getComponentName();
$componentName = new ComponentName($componentNameString);
$cacheKey = $this->getCacheKey($componentNameString);
// 1. Intentar obtener del cache
$cached = $this->cache->get($cacheKey);
if ($cached !== null) {
return GetComponentResponse::success($cached);
}
// 2. Si no está en cache, obtener del repositorio
$component = $this->repository->findByName($componentName);
if ($component === null) {
throw new ComponentNotFoundException(
"Component '{$componentNameString}' not found"
);
}
$data = $component->toArray();
// 3. Guardar en cache
$this->cache->set($cacheKey, $data, self::CACHE_TTL);
// 4. Retornar respuesta exitosa
return GetComponentResponse::success($data);
} catch (ComponentNotFoundException $e) {
return GetComponentResponse::failure($e->getMessage());
} catch (\Exception $e) {
return GetComponentResponse::failure(
'Unexpected error: ' . $e->getMessage()
);
}
}
/**
* Generar key de cache para componente
*
* @param string $componentName
* @return string
*/
private function getCacheKey(string $componentName): string
{
return "component_{$componentName}";
}
}