refactor(validators): Add support for injection components
Injection components (like theme-settings) are special components that: - Don't render visual HTML (inject code into wp_head/wp_footer) - Don't need visibility group (always enabled) - Don't need CSSGeneratorInterface (output user-provided CSS) - Don't need getVisibilityClasses (not responsive visual elements) - Update Phase01Validator to skip visibility check for injection components - Update Phase03Validator to skip CSS/visibility validations for injection components 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,16 @@ final class Phase01Validator implements PhaseValidatorInterface
|
||||
'visual_effects', 'behavior', 'layout', 'links', 'icons', 'media', 'forms'
|
||||
];
|
||||
|
||||
/**
|
||||
* Componentes especiales que NO requieren grupo visibility
|
||||
*
|
||||
* Estos son componentes de inyeccion (no visuales) que:
|
||||
* - NO renderizan HTML visual
|
||||
* - Inyectan codigo en hooks (wp_head, wp_footer)
|
||||
* - Siempre estan activos (controlados por campos vacios/llenos)
|
||||
*/
|
||||
private const INJECTION_COMPONENTS = ['theme-settings'];
|
||||
|
||||
public function validate(string $componentName, string $themePath): ValidationResult
|
||||
{
|
||||
$result = new ValidationResult();
|
||||
@@ -53,8 +63,8 @@ final class Phase01Validator implements PhaseValidatorInterface
|
||||
$this->validateGroups($schema['groups'], $result);
|
||||
}
|
||||
|
||||
// 5. Validar campos obligatorios de visibilidad
|
||||
$this->validateVisibilityFields($schema, $result);
|
||||
// 5. Validar campos obligatorios de visibilidad (excepto componentes de inyeccion)
|
||||
$this->validateVisibilityFields($schema, $componentName, $result);
|
||||
|
||||
// Estadísticas
|
||||
$totalFields = $this->countTotalFields($schema);
|
||||
@@ -184,8 +194,14 @@ final class Phase01Validator implements PhaseValidatorInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function validateVisibilityFields(array $schema, ValidationResult $result): void
|
||||
private function validateVisibilityFields(array $schema, string $componentName, ValidationResult $result): void
|
||||
{
|
||||
// Componentes de inyeccion no requieren grupo visibility
|
||||
if (in_array($componentName, self::INJECTION_COMPONENTS, true)) {
|
||||
$result->addInfo("✓ Componente de inyección '{$componentName}' - grupo visibility no requerido");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($schema['groups']['visibility'])) {
|
||||
$result->addError("Grupo 'visibility' es obligatorio y no está presente");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user