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:
157
shared/Infrastructure/Validators/ValidationResult.php
Normal file
157
shared/Infrastructure/Validators/ValidationResult.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ROITheme\Shared\Infrastructure\Validators;
|
||||
|
||||
/**
|
||||
* Resultado de una validación
|
||||
*
|
||||
* Almacena errores, advertencias, información y estadísticas
|
||||
*/
|
||||
final class ValidationResult
|
||||
{
|
||||
/**
|
||||
* @param bool $success Estado inicial de éxito
|
||||
* @param array<string> $errors Lista de errores críticos
|
||||
* @param array<string> $warnings Lista de advertencias
|
||||
* @param array<string> $info Lista de mensajes informativos
|
||||
* @param array<string, mixed> $stats Estadísticas de la validación
|
||||
*/
|
||||
public function __construct(
|
||||
private bool $success = true,
|
||||
private array $errors = [],
|
||||
private array $warnings = [],
|
||||
private array $info = [],
|
||||
private array $stats = []
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Verifica si la validación fue exitosa
|
||||
*
|
||||
* @return bool True si no hay errores, false si hay al menos un error
|
||||
*/
|
||||
public function isSuccess(): bool
|
||||
{
|
||||
return $this->success && empty($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todos los errores críticos
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getErrors(): array
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todas las advertencias
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getWarnings(): array
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todos los mensajes informativos
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getInfo(): array
|
||||
{
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todas las estadísticas
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getStats(): array
|
||||
{
|
||||
return $this->stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agrega un error crítico
|
||||
*
|
||||
* Al agregar un error, la validación se marca como fallida
|
||||
*
|
||||
* @param string $message Mensaje del error
|
||||
* @return void
|
||||
*/
|
||||
public function addError(string $message): void
|
||||
{
|
||||
$this->errors[] = $message;
|
||||
$this->success = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agrega una advertencia
|
||||
*
|
||||
* Las advertencias NO marcan la validación como fallida
|
||||
*
|
||||
* @param string $message Mensaje de advertencia
|
||||
* @return void
|
||||
*/
|
||||
public function addWarning(string $message): void
|
||||
{
|
||||
$this->warnings[] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agrega un mensaje informativo
|
||||
*
|
||||
* @param string $message Mensaje informativo
|
||||
* @return void
|
||||
*/
|
||||
public function addInfo(string $message): void
|
||||
{
|
||||
$this->info[] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establece una estadística
|
||||
*
|
||||
* @param string $key Clave de la estadística
|
||||
* @param mixed $value Valor de la estadística
|
||||
* @return void
|
||||
*/
|
||||
public function setStat(string $key, mixed $value): void
|
||||
{
|
||||
$this->stats[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cuenta total de errores
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getErrorCount(): int
|
||||
{
|
||||
return count($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cuenta total de advertencias
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWarningCount(): int
|
||||
{
|
||||
return count($this->warnings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marca la validación como fallida manualmente
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function markAsFailed(): void
|
||||
{
|
||||
$this->success = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user