Rename folders to match PHP PSR-4 autoloading conventions: - schemas → Schemas - shared → Shared - Wordpress → WordPress (in all locations) Fixes deployment issues on Linux servers where filesystem is case-sensitive. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
|
||
namespace ROITheme\Shared\Application\UseCases\SaveComponent;
|
||
|
||
/**
|
||
* SaveComponentRequest - DTO de entrada para guardar componente
|
||
*
|
||
* RESPONSABILIDAD: Encapsular los datos de entrada para el Use Case de guardar un componente
|
||
*
|
||
* CARACTER<45>STICAS:
|
||
* - Inmutable
|
||
* - Sin l<>gica de negocio
|
||
* - Validaci<63>n b<>sica de tipos (PHP har<61> type checking)
|
||
*
|
||
* USO:
|
||
* ```php
|
||
* $request = new SaveComponentRequest('top_bar', [
|
||
* 'configuration' => ['content' => ['message_text' => 'Welcome']],
|
||
* 'visibility' => ['desktop' => true, 'mobile' => true],
|
||
* 'is_enabled' => true
|
||
* ]);
|
||
* ```
|
||
*
|
||
* @package ROITheme\Shared\Application\UseCases\SaveComponent
|
||
*/
|
||
final readonly class SaveComponentRequest
|
||
{
|
||
/**
|
||
* @param string $componentName Nombre del componente a guardar (e.g., 'top_bar', 'footer_cta')
|
||
* @param array $data Datos del componente (configuration, visibility, is_enabled, schema_version)
|
||
*/
|
||
public function __construct(
|
||
private string $componentName,
|
||
private array $data
|
||
) {}
|
||
|
||
/**
|
||
* Obtener nombre del componente
|
||
*
|
||
* @return string
|
||
*/
|
||
public function getComponentName(): string
|
||
{
|
||
return $this->componentName;
|
||
}
|
||
|
||
/**
|
||
* Obtener datos del componente
|
||
*
|
||
* @return array
|
||
*/
|
||
public function getData(): array
|
||
{
|
||
return $this->data;
|
||
}
|
||
|
||
/**
|
||
* Factory method: Crear desde array
|
||
*
|
||
* <20>til para crear desde datos POST/JSON
|
||
*
|
||
* @param array $data Array con keys 'component_name' y 'data'
|
||
* @return self
|
||
*/
|
||
public static function fromArray(array $data): self
|
||
{
|
||
return new self(
|
||
$data['component_name'] ?? '',
|
||
$data['data'] ?? []
|
||
);
|
||
}
|
||
}
|