47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
/**
|
|
* Value object representing domain-specific configuration.
|
|
*
|
|
* Holds theme key, GTM container ID, and CMP (Consent Management Platform) URL
|
|
* for a specific domain. Used by DomainConfigProvider to resolve configuration
|
|
* based on the request host.
|
|
*/
|
|
final readonly class DomainConfig
|
|
{
|
|
public const DEFAULT_THEME = 'base';
|
|
|
|
public function __construct(
|
|
public string $theme = self::DEFAULT_THEME,
|
|
public string $gtmId = '',
|
|
public string $cmpUrl = '',
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Creates a DomainConfig instance from a configuration array.
|
|
*
|
|
* @param array{theme?: string, gtm_id?: string, cmp_url?: string} $config The configuration array
|
|
*/
|
|
public static function fromArray(array $config): self
|
|
{
|
|
return new self(
|
|
theme: $config['theme'] ?? self::DEFAULT_THEME,
|
|
gtmId: $config['gtm_id'] ?? '',
|
|
cmpUrl: $config['cmp_url'] ?? '',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Creates a default DomainConfig instance with base theme and empty tracking values.
|
|
*/
|
|
public static function default(): self
|
|
{
|
|
return new self();
|
|
}
|
|
}
|