feat: tracking integration with GTM and CMP

This commit is contained in:
Björn Fromme
2026-03-16 12:02:59 +01:00
parent 11ab98b3d8
commit 3957f6bd09
21 changed files with 453 additions and 51 deletions
+46
View File
@@ -0,0 +1,46 @@
<?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();
}
}