From f327038e2507a21e40f8eb7a03a7f56e70046bf0 Mon Sep 17 00:00:00 2001 From: Tatevik Date: Sun, 4 May 2025 20:36:05 +0400 Subject: [PATCH 1/2] ISSUE-345: fix alias error --- composer.json | 7 ++++++- src/Domain/Repository/AbstractRepository.php | 10 ---------- src/Domain/Repository/Messaging/MessageRepository.php | 2 +- tests/Unit/Domain/Repository/DummyRepository.php | 5 ----- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index bf931e41..285f0d3e 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ { "name": "Xheni Myrtaj", "email": "xheni@phplist.com", - "role": "Maintainer" + "role": "Former developer" }, { "name": "Oliver Klee", @@ -25,6 +25,11 @@ "name": "Sam Tuke", "email": "mail@samtuke.com", "role": "Former developer" + }, + { + "name": "Tatevik Grigoryan", + "email": "tatevik@phplist.com", + "role": "Maintainer" } ], "support": { diff --git a/src/Domain/Repository/AbstractRepository.php b/src/Domain/Repository/AbstractRepository.php index 9fff90b7..18328e49 100644 --- a/src/Domain/Repository/AbstractRepository.php +++ b/src/Domain/Repository/AbstractRepository.php @@ -5,7 +5,6 @@ namespace PhpList\Core\Domain\Repository; use Doctrine\ORM\EntityRepository; -use LogicException; use PhpList\Core\Domain\Model\Interfaces\DomainModel; /** @@ -49,13 +48,4 @@ public function remove(DomainModel $model): void $this->getEntityManager()->remove($model); $this->getEntityManager()->flush(); } - - public function getAlias(): string - { - if (!$this->alias) { - throw new LogicException('Alias not set in repository: ' . static::class); - } - - return $this->alias; - } } diff --git a/src/Domain/Repository/Messaging/MessageRepository.php b/src/Domain/Repository/Messaging/MessageRepository.php index c23097ef..a559ba91 100644 --- a/src/Domain/Repository/Messaging/MessageRepository.php +++ b/src/Domain/Repository/Messaging/MessageRepository.php @@ -24,7 +24,7 @@ public function getByOwnerId(int $ownerId): array /** @return Message[] */ public function getFilteredAfterId(int $lastId, int $limit, ?FilterRequestInterface $filter = null): array { - $queryBuilder = $this->createQueryBuilder($this->getAlias()); + $queryBuilder = $this->createQueryBuilder('m'); if ($filter instanceof MessageFilter && $filter->getOwner() !== null) { $queryBuilder->andWhere('IDENTITY(m.owner) = :ownerId') diff --git a/tests/Unit/Domain/Repository/DummyRepository.php b/tests/Unit/Domain/Repository/DummyRepository.php index b9b2bfbe..e16b612e 100644 --- a/tests/Unit/Domain/Repository/DummyRepository.php +++ b/tests/Unit/Domain/Repository/DummyRepository.php @@ -18,11 +18,6 @@ public function __construct(private readonly QueryBuilder $queryBuilder) { } - public function getAlias(): string - { - return 'dummy'; - } - /** Doctrine normally injects the QB through $this->createQueryBuilder(). */ protected function createQueryBuilder(string $alias): QueryBuilder { From 2d3e26098dfbb70868e0e5a00b09b0141811d277 Mon Sep 17 00:00:00 2001 From: Tatevik Date: Sun, 4 May 2025 20:53:28 +0400 Subject: [PATCH 2/2] ISSUE-345: fix doctrine --- src/Domain/Model/Messaging/Message/MessageFormat.php | 10 +++++----- src/Domain/Model/Messaging/TemplateImage.php | 4 ++-- src/Domain/Model/Subscription/SubscriberAttribute.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Domain/Model/Messaging/Message/MessageFormat.php b/src/Domain/Model/Messaging/Message/MessageFormat.php index 90fc56f0..de4836e0 100644 --- a/src/Domain/Model/Messaging/Message/MessageFormat.php +++ b/src/Domain/Model/Messaging/Message/MessageFormat.php @@ -17,19 +17,19 @@ class MessageFormat implements EmbeddableInterface #[ORM\Column(name: 'sendformat', type: 'string', length: 20, nullable: true)] private ?string $sendFormat = null; - #[ORM\Column(name: 'astext', type: 'integer', options: ['default' => 0])] + #[ORM\Column(name: 'astext', type: 'boolean', options: ['default' => false])] private bool $asText = false; - #[ORM\Column(name: 'ashtml', type: 'integer', options: ['default' => 0])] + #[ORM\Column(name: 'ashtml', type: 'boolean', options: ['default' => false])] private bool $asHtml = false; - #[ORM\Column(name: 'aspdf', type: 'integer', options: ['default' => 0])] + #[ORM\Column(name: 'aspdf', type: 'boolean', options: ['default' => false])] private bool $asPdf = false; - #[ORM\Column(name: 'astextandhtml', type: 'integer', options: ['default' => 0])] + #[ORM\Column(name: 'astextandhtml', type: 'boolean', options: ['default' => false])] private bool $asTextAndHtml = false; - #[ORM\Column(name: 'astextandpdf', type: 'integer', options: ['default' => 0])] + #[ORM\Column(name: 'astextandpdf', type: 'boolean', options: ['default' => false])] private bool $asTextAndPdf = false; public const FORMAT_TEXT = 'text'; diff --git a/src/Domain/Model/Messaging/TemplateImage.php b/src/Domain/Model/Messaging/TemplateImage.php index 09ff6b2e..732bba4c 100644 --- a/src/Domain/Model/Messaging/TemplateImage.php +++ b/src/Domain/Model/Messaging/TemplateImage.php @@ -19,8 +19,8 @@ class TemplateImage implements DomainModel, Identity #[ORM\GeneratedValue] private ?int $id = null; - #[ORM\ManyToOne(targetEntity: Template::class)] - #[ORM\JoinColumn(name: 'template', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] + #[ORM\ManyToOne(targetEntity: Template::class, inversedBy: 'images')] + #[ORM\JoinColumn(name: 'template', referencedColumnName: 'id', nullable: false)] private Template $template; #[ORM\Column(name: 'mimetype', type: 'string', length: 100, nullable: true)] diff --git a/src/Domain/Model/Subscription/SubscriberAttribute.php b/src/Domain/Model/Subscription/SubscriberAttribute.php index 8484ff1d..72c23b65 100644 --- a/src/Domain/Model/Subscription/SubscriberAttribute.php +++ b/src/Domain/Model/Subscription/SubscriberAttribute.php @@ -21,7 +21,7 @@ class SubscriberAttribute implements DomainModel private SubscriberAttributeDefinition $attributeDefinition; #[ORM\Id] - #[ORM\ManyToOne(targetEntity: Subscriber::class)] + #[ORM\ManyToOne(targetEntity: Subscriber::class, inversedBy: 'attributes')] #[ORM\JoinColumn(name: 'userid', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] private Subscriber $subscriber;