feat: add Channel domain cluster (Platform, ChannelField, ArticleTypePlatformConfig, AttributeMapping)

This commit is contained in:
Simon Kuehn 2026-05-14 04:28:41 +00:00
parent 3cc8f57f11
commit 11c894b8a4
4 changed files with 193 additions and 0 deletions

View file

@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace App\Domain\Channel;
use App\Domain\Article\ArticleType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity]
#[ORM\Table(name: 'article_type_platform_configs', schema: 'app')]
#[ORM\UniqueConstraint(columns: ['article_type_id', 'platform_id'])]
class ArticleTypePlatformConfig
{
#[ORM\Id]
#[ORM\Column(type: 'uuid')]
private Uuid $id;
#[ORM\ManyToOne(targetEntity: ArticleType::class)]
#[ORM\JoinColumn(nullable: false)]
private ArticleType $articleType;
#[ORM\ManyToOne(targetEntity: Platform::class)]
#[ORM\JoinColumn(nullable: false)]
private Platform $platform;
#[ORM\Column(type: 'string', length: 255)]
private string $categoryId;
/** @var Collection<int, AttributeMapping> */
#[ORM\OneToMany(mappedBy: 'platformConfig', targetEntity: AttributeMapping::class, cascade: ['persist', 'remove'])]
private Collection $attributeMappings;
public function __construct(ArticleType $articleType, Platform $platform, string $categoryId)
{
$this->id = Uuid::v7();
$this->articleType = $articleType;
$this->platform = $platform;
$this->categoryId = $categoryId;
$this->attributeMappings = new ArrayCollection();
}
public function getId(): Uuid { return $this->id; }
public function getArticleType(): ArticleType { return $this->articleType; }
public function getPlatform(): Platform { return $this->platform; }
public function getCategoryId(): string { return $this->categoryId; }
public function setCategoryId(string $categoryId): void { $this->categoryId = $categoryId; }
/** @return Collection<int, AttributeMapping> */
public function getAttributeMappings(): Collection { return $this->attributeMappings; }
}

View file

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Domain\Channel;
use App\Domain\Article\AttributeDefinition;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity]
#[ORM\Table(name: 'attribute_mappings', schema: 'app')]
#[ORM\UniqueConstraint(columns: ['platform_config_id', 'attribute_definition_id'])]
class AttributeMapping
{
#[ORM\Id]
#[ORM\Column(type: 'uuid')]
private Uuid $id;
#[ORM\ManyToOne(targetEntity: ArticleTypePlatformConfig::class, inversedBy: 'attributeMappings')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ArticleTypePlatformConfig $platformConfig;
#[ORM\ManyToOne(targetEntity: AttributeDefinition::class)]
#[ORM\JoinColumn(nullable: false)]
private AttributeDefinition $attributeDefinition;
#[ORM\ManyToOne(targetEntity: ChannelField::class)]
#[ORM\JoinColumn(nullable: false)]
private ChannelField $channelField;
#[ORM\Column(type: 'string', length: 100, nullable: true)]
private ?string $transformer = null;
public function __construct(
ArticleTypePlatformConfig $platformConfig,
AttributeDefinition $attributeDefinition,
ChannelField $channelField,
) {
$this->id = Uuid::v7();
$this->platformConfig = $platformConfig;
$this->attributeDefinition = $attributeDefinition;
$this->channelField = $channelField;
}
public function getId(): Uuid { return $this->id; }
public function getPlatformConfig(): ArticleTypePlatformConfig { return $this->platformConfig; }
public function getAttributeDefinition(): AttributeDefinition { return $this->attributeDefinition; }
public function getChannelField(): ChannelField { return $this->channelField; }
public function getTransformer(): ?string { return $this->transformer; }
public function setTransformer(?string $transformer): void { $this->transformer = $transformer; }
}

View file

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Domain\Channel;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity]
#[ORM\Table(name: 'channel_fields', schema: 'app')]
class ChannelField
{
#[ORM\Id]
#[ORM\Column(type: 'uuid')]
private Uuid $id;
#[ORM\ManyToOne(targetEntity: Platform::class)]
#[ORM\JoinColumn(nullable: false)]
private Platform $platform;
#[ORM\Column(type: 'string', length: 255)]
private string $label;
#[ORM\Column(type: 'string', length: 500)]
private string $path;
public function __construct(Platform $platform, string $label, string $path)
{
$this->id = Uuid::v7();
$this->platform = $platform;
$this->label = $label;
$this->path = $path;
}
public function getId(): Uuid { return $this->id; }
public function getPlatform(): Platform { return $this->platform; }
public function getLabel(): string { return $this->label; }
public function setLabel(string $label): void { $this->label = $label; }
public function getPath(): string { return $this->path; }
public function setPath(string $path): void { $this->path = $path; }
}

View file

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace App\Domain\Channel;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity]
#[ORM\Table(name: 'platforms', schema: 'app')]
class Platform
{
#[ORM\Id]
#[ORM\Column(type: 'uuid')]
private Uuid $id;
#[ORM\Column(type: 'string', length: 100, unique: true)]
private string $type;
#[ORM\Column(type: 'string', length: 255)]
private string $label;
/** @var array<string, mixed> */
#[ORM\Column(type: 'json')]
private array $config = [];
public function __construct(string $type, string $label)
{
$this->id = Uuid::v7();
$this->type = $type;
$this->label = $label;
}
public function getId(): Uuid { return $this->id; }
public function getType(): string { return $this->type; }
public function getLabel(): string { return $this->label; }
public function setLabel(string $label): void { $this->label = $label; }
/** @return array<string, mixed> */
public function getConfig(): array { return $this->config; }
/** @param array<string, mixed> $config */
public function setConfig(array $config): void { $this->config = $config; }
}