|
9 | 9 | use Doctrine\Common\Collections\Collection; |
10 | 10 | use Doctrine\ORM\Mapping as ORM; |
11 | 11 | use PhpList\Core\Domain\Repository\Subscription\SubscriberRepository; |
12 | | -use Symfony\Component\Serializer\Annotation\Ignore; |
13 | 12 | use Symfony\Component\Serializer\Annotation\SerializedName; |
14 | 13 | use PhpList\Core\Domain\Model\Interfaces\CreationDate; |
15 | 14 | use PhpList\Core\Domain\Model\Interfaces\DomainModel; |
|
24 | 23 | * This class represents subscriber who can subscribe to multiple subscriber lists and can receive email messages from |
25 | 24 | * campaigns for those subscriber lists. |
26 | 25 | * @author Oliver Klee <[email protected]> |
| 26 | + * @author Tatevik Grigoryan <[email protected]> |
27 | 27 | */ |
28 | 28 | #[ORM\Entity(repositoryClass: SubscriberRepository::class)] |
29 | 29 | #[ORM\Table(name: 'phplist_user_user')] |
@@ -83,16 +83,28 @@ class Subscriber implements DomainModel, Identity, CreationDate, ModificationDat |
83 | 83 | private ?string $extraData; |
84 | 84 |
|
85 | 85 | #[ORM\OneToMany( |
86 | | - targetEntity: 'PhpList\Core\Domain\Model\Subscription\Subscription', |
| 86 | + targetEntity: Subscription::class, |
87 | 87 | mappedBy: 'subscriber', |
88 | 88 | cascade: ['remove'], |
89 | 89 | orphanRemoval: true, |
90 | 90 | )] |
91 | 91 | private Collection $subscriptions; |
92 | 92 |
|
| 93 | + /** |
| 94 | + * @var Collection<int, SubscriberAttribute> |
| 95 | + */ |
| 96 | + #[ORM\OneToMany( |
| 97 | + targetEntity: SubscriberAttribute::class, |
| 98 | + mappedBy: 'subscriber', |
| 99 | + cascade: ['persist', 'remove'], |
| 100 | + orphanRemoval: true |
| 101 | + )] |
| 102 | + private Collection $attributes; |
| 103 | + |
93 | 104 | public function __construct() |
94 | 105 | { |
95 | 106 | $this->subscriptions = new ArrayCollection(); |
| 107 | + $this->attributes = new ArrayCollection(); |
96 | 108 | $this->extraData = ''; |
97 | 109 | } |
98 | 110 |
|
@@ -223,4 +235,24 @@ public function getSubscribedLists(): Collection |
223 | 235 |
|
224 | 236 | return $result; |
225 | 237 | } |
| 238 | + |
| 239 | + public function getAttributes(): Collection |
| 240 | + { |
| 241 | + return $this->attributes; |
| 242 | + } |
| 243 | + |
| 244 | + public function addAttribute(SubscriberAttribute $attribute): self |
| 245 | + { |
| 246 | + if (!$this->attributes->contains($attribute)) { |
| 247 | + $this->attributes[] = $attribute; |
| 248 | + } |
| 249 | + |
| 250 | + return $this; |
| 251 | + } |
| 252 | + |
| 253 | + public function removeAttribute(SubscriberAttribute $attribute): self |
| 254 | + { |
| 255 | + $this->attributes->removeElement($attribute); |
| 256 | + return $this; |
| 257 | + } |
226 | 258 | } |
0 commit comments