feat(visibility): sistema de visibilidad por tipo de página
- Añadir PageVisibility use case y repositorio - Implementar PageTypeDetector para detectar home/single/page/archive - Actualizar FieldMappers con soporte show_on_[page_type] - Extender FormBuilders con UI de visibilidad por página - Refactorizar Renderers para evaluar visibilidad dinámica - Limpiar schemas removiendo campos de visibilidad legacy - Añadir MigrationCommand para migrar configuraciones existentes - Implementar adsense-loader.js para carga lazy de ads - Actualizar front-page.php con nueva estructura - Extender DIContainer con nuevos servicios 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,9 @@ final readonly class ComponentConfiguration
|
||||
'widget_3', // Widget 3 del footer (menú)
|
||||
'newsletter', // Sección newsletter del footer
|
||||
'footer_bottom', // Pie del footer (copyright)
|
||||
|
||||
// Sistema de visibilidad por página
|
||||
'_page_visibility', // Visibilidad por tipo de página (home, posts, pages, archives, search)
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
90
Shared/Domain/ValueObjects/PageType.php
Normal file
90
Shared/Domain/ValueObjects/PageType.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ROITheme\Shared\Domain\ValueObjects;
|
||||
|
||||
/**
|
||||
* Value Object que representa los tipos de página válidos
|
||||
*
|
||||
* @package ROITheme\Shared\Domain\ValueObjects
|
||||
*/
|
||||
final class PageType
|
||||
{
|
||||
public const HOME = 'home';
|
||||
public const POST = 'post';
|
||||
public const PAGE = 'page';
|
||||
public const ARCHIVE = 'archive';
|
||||
public const SEARCH = 'search';
|
||||
public const UNKNOWN = 'unknown';
|
||||
|
||||
private const VALID_TYPES = [
|
||||
self::HOME,
|
||||
self::POST,
|
||||
self::PAGE,
|
||||
self::ARCHIVE,
|
||||
self::SEARCH,
|
||||
self::UNKNOWN,
|
||||
];
|
||||
|
||||
private function __construct(
|
||||
private readonly string $value
|
||||
) {}
|
||||
|
||||
public static function fromString(string $type): self
|
||||
{
|
||||
if (!in_array($type, self::VALID_TYPES, true)) {
|
||||
return new self(self::UNKNOWN);
|
||||
}
|
||||
return new self($type);
|
||||
}
|
||||
|
||||
public static function home(): self
|
||||
{
|
||||
return new self(self::HOME);
|
||||
}
|
||||
|
||||
public static function post(): self
|
||||
{
|
||||
return new self(self::POST);
|
||||
}
|
||||
|
||||
public static function page(): self
|
||||
{
|
||||
return new self(self::PAGE);
|
||||
}
|
||||
|
||||
public static function archive(): self
|
||||
{
|
||||
return new self(self::ARCHIVE);
|
||||
}
|
||||
|
||||
public static function search(): self
|
||||
{
|
||||
return new self(self::SEARCH);
|
||||
}
|
||||
|
||||
public function value(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function equals(self $other): bool
|
||||
{
|
||||
return $this->value === $other->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna el nombre del campo de visibilidad correspondiente
|
||||
*/
|
||||
public function toVisibilityField(): string
|
||||
{
|
||||
return match ($this->value) {
|
||||
self::HOME => 'show_on_home',
|
||||
self::POST => 'show_on_posts',
|
||||
self::PAGE => 'show_on_pages',
|
||||
self::ARCHIVE => 'show_on_archives',
|
||||
self::SEARCH => 'show_on_search',
|
||||
default => 'show_on_posts',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user