feat(exclusions): Implement component exclusion system (Plan 99.11)
Adds ability to exclude components from specific: - Categories (by slug or term_id) - Post/Page IDs - URL patterns (substring or regex) Architecture: - Domain: Value Objects (CategoryExclusion, PostIdExclusion, UrlPatternExclusion, ExclusionRuleSet) + Contracts - Application: EvaluateExclusionsUseCase + EvaluateComponentVisibilityUseCase (orchestrator) - Infrastructure: WordPressExclusionRepository, WordPressPageContextProvider, WordPressServerRequestProvider - Admin: ExclusionFormPartial (reusable UI), ExclusionFieldProcessor, JS toggle The PageVisibilityHelper now uses the orchestrator UseCase that combines page-type visibility (Plan 99.10) with exclusion rules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
36
Shared/Domain/Contracts/ExclusionRepositoryInterface.php
Normal file
36
Shared/Domain/Contracts/ExclusionRepositoryInterface.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ROITheme\Shared\Domain\Contracts;
|
||||
|
||||
use ROITheme\Shared\Domain\ValueObjects\ExclusionRuleSet;
|
||||
|
||||
/**
|
||||
* Contrato para acceder a la configuracion de exclusiones
|
||||
*
|
||||
* Metodos: 3 (cumple ISP < 5 metodos)
|
||||
*
|
||||
* @package ROITheme\Shared\Domain\Contracts
|
||||
*/
|
||||
interface ExclusionRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Obtiene las exclusiones configuradas para un componente
|
||||
*
|
||||
* @param string $componentName Nombre del componente (kebab-case)
|
||||
* @return ExclusionRuleSet Configuracion de exclusiones
|
||||
*/
|
||||
public function getExclusions(string $componentName): ExclusionRuleSet;
|
||||
|
||||
/**
|
||||
* Guarda la configuracion de exclusiones de un componente
|
||||
*
|
||||
* @param ExclusionRuleSet $exclusions Configuracion a guardar
|
||||
*/
|
||||
public function saveExclusions(ExclusionRuleSet $exclusions): void;
|
||||
|
||||
/**
|
||||
* Verifica si existe configuracion de exclusiones para un componente
|
||||
*/
|
||||
public function hasExclusions(string $componentName): bool;
|
||||
}
|
||||
33
Shared/Domain/Contracts/PageContextProviderInterface.php
Normal file
33
Shared/Domain/Contracts/PageContextProviderInterface.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ROITheme\Shared\Domain\Contracts;
|
||||
|
||||
/**
|
||||
* Contrato para obtener el contexto de la pagina actual
|
||||
*
|
||||
* Abstrae la obtencion de datos del contexto actual (WordPress).
|
||||
* Permite testear UseCases sin dependencia de WordPress.
|
||||
*
|
||||
* v1.1: Renombrado de ExclusionEvaluatorInterface (nombre semantico incorrecto)
|
||||
* El nombre refleja que PROVEE contexto, no que EVALUA.
|
||||
*
|
||||
* Metodos: 1 (cumple ISP < 5 metodos)
|
||||
*
|
||||
* @package ROITheme\Shared\Domain\Contracts
|
||||
*/
|
||||
interface PageContextProviderInterface
|
||||
{
|
||||
/**
|
||||
* Obtiene el contexto actual para evaluacion de exclusiones
|
||||
*
|
||||
* @return array{
|
||||
* post_id: int,
|
||||
* categories: array<array{term_id: int, slug: string, name: string}>,
|
||||
* url: string,
|
||||
* request_uri: string,
|
||||
* post_type: string
|
||||
* }
|
||||
*/
|
||||
public function getCurrentContext(): array;
|
||||
}
|
||||
27
Shared/Domain/Contracts/ServerRequestProviderInterface.php
Normal file
27
Shared/Domain/Contracts/ServerRequestProviderInterface.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ROITheme\Shared\Domain\Contracts;
|
||||
|
||||
/**
|
||||
* Contrato para obtener datos del request HTTP
|
||||
*
|
||||
* Encapsula el acceso a $_SERVER para:
|
||||
* - Evitar acceso directo a superglobales en Infrastructure
|
||||
* - Permitir testear sin dependencia de $_SERVER
|
||||
*
|
||||
* v1.1: Nuevo - encapsular acceso a $_SERVER
|
||||
*
|
||||
* Metodos: 1 (cumple ISP < 5 metodos)
|
||||
*
|
||||
* @package ROITheme\Shared\Domain\Contracts
|
||||
*/
|
||||
interface ServerRequestProviderInterface
|
||||
{
|
||||
/**
|
||||
* Obtiene el Request URI actual
|
||||
*
|
||||
* @return string URI del request (ej: "/blog/mi-post/")
|
||||
*/
|
||||
public function getRequestUri(): string;
|
||||
}
|
||||
Reference in New Issue
Block a user