Migración completa a Clean Architecture con componentes funcionales
- Reorganización de estructura: Admin/, Public/, Shared/, Schemas/ - 12 componentes migrados: TopNotificationBar, Navbar, CtaLetsTalk, Hero, FeaturedImage, TableOfContents, CtaBoxSidebar, SocialShare, CtaPost, RelatedPost, ContactForm, Footer - Panel de administración con tabs Bootstrap 5 funcionales - Schemas JSON para configuración de componentes - Renderers dinámicos con CSSGeneratorService (cero CSS hardcodeado) - FormBuilders para UI admin con Design System consistente - Fix: Bootstrap JS cargado en header para tabs funcionales - Fix: buildTextInput maneja valores mixed (bool/string) - Eliminación de estructura legacy (src/, admin/, assets/css/componente-*) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ROITheme\Shared\Application\UseCases\DeleteComponent;
|
||||
|
||||
use ROITheme\Shared\Domain\Contracts\ComponentRepositoryInterface;
|
||||
use ROITheme\Shared\Domain\Contracts\CacheServiceInterface;
|
||||
use ROITheme\Shared\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\Shared\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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user