Add tags entities
[MAILPOET-4440]
This commit is contained in:
@@ -168,9 +168,16 @@ class SubscriberEntity {
|
||||
*/
|
||||
private $subscriberCustomFields;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="MailPoet\Entities\SubscriberTagEntity", mappedBy="subscriber", orphanRemoval=true)
|
||||
* @var Collection<int, SubscriberTagEntity>
|
||||
*/
|
||||
private $subscriberTags;
|
||||
|
||||
public function __construct() {
|
||||
$this->subscriberSegments = new ArrayCollection();
|
||||
$this->subscriberCustomFields = new ArrayCollection();
|
||||
$this->subscriberTags = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,6 +453,13 @@ class SubscriberEntity {
|
||||
return $this->subscriberCustomFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, SubscriberTagEntity>
|
||||
*/
|
||||
public function getSubscriberTags() {
|
||||
return $this->subscriberTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float|null
|
||||
*/
|
||||
|
50
mailpoet/lib/Entities/SubscriberTagEntity.php
Normal file
50
mailpoet/lib/Entities/SubscriberTagEntity.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="subscriber_tag")
|
||||
*/
|
||||
class SubscriberTagEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\TagEntity")
|
||||
* @var TagEntity|null
|
||||
*/
|
||||
private $tag;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\SubscriberEntity", inversedBy="subscriberTags")
|
||||
* @var SubscriberEntity|null
|
||||
*/
|
||||
private $subscriber;
|
||||
|
||||
public function __construct(
|
||||
TagEntity $tag,
|
||||
SubscriberEntity $subscriber
|
||||
) {
|
||||
$this->tag = $tag;
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
|
||||
public function getTag(): ?TagEntity {
|
||||
$this->safelyLoadToOneAssociation('tag');
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
public function getSubscriber(): ?SubscriberEntity {
|
||||
$this->safelyLoadToOneAssociation('subscriber');
|
||||
return $this->subscriber;
|
||||
}
|
||||
}
|
56
mailpoet/lib/Entities/TagEntity.php
Normal file
56
mailpoet/lib/Entities/TagEntity.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="tags")
|
||||
*/
|
||||
class TagEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
* @Assert\NotBlank()
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
public function __construct(
|
||||
string $name,
|
||||
string $description = ''
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): void {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getDescription(): string {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(string $description): void {
|
||||
$this->description = $description;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user