Apply safe to load association trait to all toOne associations
[MAILPOET-2818]
This commit is contained in:
committed by
Veljko V
parent
217b9194db
commit
63a2bed8bf
@ -6,10 +6,10 @@ use DateTimeInterface;
|
|||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||||
use MailPoetVendor\Doctrine\Common\Collections\ArrayCollection;
|
use MailPoetVendor\Doctrine\Common\Collections\ArrayCollection;
|
||||||
use MailPoetVendor\Doctrine\Common\Collections\Criteria;
|
use MailPoetVendor\Doctrine\Common\Collections\Criteria;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityNotFoundException;
|
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
|
use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
@ -39,6 +39,7 @@ class NewsletterEntity {
|
|||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
use UpdatedAtTrait;
|
use UpdatedAtTrait;
|
||||||
use DeletedAtTrait;
|
use DeletedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string")
|
* @ORM\Column(type="string")
|
||||||
@ -342,14 +343,8 @@ class NewsletterEntity {
|
|||||||
* @return NewsletterEntity|null
|
* @return NewsletterEntity|null
|
||||||
*/
|
*/
|
||||||
public function getParent() {
|
public function getParent() {
|
||||||
try {
|
$this->safelyLoadToOneAssociation('parent');
|
||||||
if ($this->parent && $this->parent->getId()) {
|
return $this->parent;
|
||||||
return $this->parent;
|
|
||||||
}
|
|
||||||
} catch (EntityNotFoundException $enf) {
|
|
||||||
$this->setParent(null);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Entities;
|
|||||||
|
|
||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||||
use MailPoetVendor\Doctrine\Common\Collections\ArrayCollection;
|
use MailPoetVendor\Doctrine\Common\Collections\ArrayCollection;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
@ -16,6 +17,7 @@ class NewsletterLinkEntity {
|
|||||||
use AutoincrementedIdTrait;
|
use AutoincrementedIdTrait;
|
||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
use UpdatedAtTrait;
|
use UpdatedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||||
@ -56,6 +58,7 @@ class NewsletterLinkEntity {
|
|||||||
* @return NewsletterEntity|null
|
* @return NewsletterEntity|null
|
||||||
*/
|
*/
|
||||||
public function getNewsletter() {
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
return $this->newsletter;
|
return $this->newsletter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +66,7 @@ class NewsletterLinkEntity {
|
|||||||
* @return SendingQueueEntity|null
|
* @return SendingQueueEntity|null
|
||||||
*/
|
*/
|
||||||
public function getQueue() {
|
public function getQueue() {
|
||||||
|
$this->safelyLoadToOneAssociation('queue');
|
||||||
return $this->queue;
|
return $this->queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Entities;
|
|||||||
|
|
||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
@ -15,6 +16,8 @@ class NewsletterOptionEntity {
|
|||||||
use AutoincrementedIdTrait;
|
use AutoincrementedIdTrait;
|
||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
use UpdatedAtTrait;
|
use UpdatedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
@ -52,6 +55,7 @@ class NewsletterOptionEntity {
|
|||||||
* @return NewsletterEntity
|
* @return NewsletterEntity
|
||||||
*/
|
*/
|
||||||
public function getNewsletter() {
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
return $this->newsletter;
|
return $this->newsletter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +70,7 @@ class NewsletterOptionEntity {
|
|||||||
* @return NewsletterOptionFieldEntity
|
* @return NewsletterOptionFieldEntity
|
||||||
*/
|
*/
|
||||||
public function getOptionField() {
|
public function getOptionField() {
|
||||||
|
$this->safelyLoadToOneAssociation('optionField');
|
||||||
return $this->optionField;
|
return $this->optionField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace MailPoet\Entities;
|
|||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
|
use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
|
||||||
@ -25,6 +26,7 @@ class SendingQueueEntity {
|
|||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
use UpdatedAtTrait;
|
use UpdatedAtTrait;
|
||||||
use DeletedAtTrait;
|
use DeletedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="json_or_serialized")
|
* @ORM\Column(type="json_or_serialized")
|
||||||
@ -183,6 +185,7 @@ class SendingQueueEntity {
|
|||||||
* @return ScheduledTaskEntity
|
* @return ScheduledTaskEntity
|
||||||
*/
|
*/
|
||||||
public function getTask() {
|
public function getTask() {
|
||||||
|
$this->safelyLoadToOneAssociation('task');
|
||||||
return $this->task;
|
return $this->task;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +197,7 @@ class SendingQueueEntity {
|
|||||||
* @return NewsletterEntity
|
* @return NewsletterEntity
|
||||||
*/
|
*/
|
||||||
public function getNewsletter() {
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
return $this->newsletter;
|
return $this->newsletter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Entities;
|
|||||||
|
|
||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ class StatisticsClickEntity {
|
|||||||
use AutoincrementedIdTrait;
|
use AutoincrementedIdTrait;
|
||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
use UpdatedAtTrait;
|
use UpdatedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||||
@ -48,4 +50,27 @@ class StatisticsClickEntity {
|
|||||||
*/
|
*/
|
||||||
private $count;
|
private $count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return NewsletterEntity|null
|
||||||
|
*/
|
||||||
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
|
return $this->newsletter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SendingQueueEntity|null
|
||||||
|
*/
|
||||||
|
public function getQueue() {
|
||||||
|
$this->safelyLoadToOneAssociation('queue');
|
||||||
|
return $this->queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return NewsletterLinkEntity
|
||||||
|
*/
|
||||||
|
public function getLink() {
|
||||||
|
$this->safelyLoadToOneAssociation('link');
|
||||||
|
return $this->link;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Entities;
|
|||||||
|
|
||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,6 +14,7 @@ use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
|||||||
class StatisticsOpenEntity {
|
class StatisticsOpenEntity {
|
||||||
use AutoincrementedIdTrait;
|
use AutoincrementedIdTrait;
|
||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||||
@ -34,4 +36,19 @@ class StatisticsOpenEntity {
|
|||||||
*/
|
*/
|
||||||
private $subscriberId;
|
private $subscriberId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return NewsletterEntity|null
|
||||||
|
*/
|
||||||
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
|
return $this->newsletter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SendingQueueEntity|null
|
||||||
|
*/
|
||||||
|
public function getQueue() {
|
||||||
|
$this->safelyLoadToOneAssociation('queue');
|
||||||
|
return $this->queue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Entities;
|
|||||||
|
|
||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,6 +14,7 @@ use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
|||||||
class StatisticsUnsubscribeEntity {
|
class StatisticsUnsubscribeEntity {
|
||||||
use AutoincrementedIdTrait;
|
use AutoincrementedIdTrait;
|
||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||||
@ -34,4 +36,19 @@ class StatisticsUnsubscribeEntity {
|
|||||||
*/
|
*/
|
||||||
private $subscriberId;
|
private $subscriberId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return NewsletterEntity|null
|
||||||
|
*/
|
||||||
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
|
return $this->newsletter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SendingQueueEntity|null
|
||||||
|
*/
|
||||||
|
public function getQueue() {
|
||||||
|
$this->safelyLoadToOneAssociation('queue');
|
||||||
|
return $this->queue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Entities;
|
|||||||
|
|
||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ class StatisticsWooCommercePurchaseEntity {
|
|||||||
use AutoincrementedIdTrait;
|
use AutoincrementedIdTrait;
|
||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
use UpdatedAtTrait;
|
use UpdatedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||||
@ -70,4 +72,36 @@ class StatisticsWooCommercePurchaseEntity {
|
|||||||
$this->orderCurrency = $orderCurrency;
|
$this->orderCurrency = $orderCurrency;
|
||||||
$this->orderPriceTotal = $orderPriceTotal;
|
$this->orderPriceTotal = $orderPriceTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return NewsletterEntity
|
||||||
|
*/
|
||||||
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
|
return $this->newsletter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SendingQueueEntity
|
||||||
|
*/
|
||||||
|
public function getQueue() {
|
||||||
|
$this->safelyLoadToOneAssociation('queue');
|
||||||
|
return $this->queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SubscriberEntity|null
|
||||||
|
*/
|
||||||
|
public function getSubscriber() {
|
||||||
|
$this->safelyLoadToOneAssociation('subscriber');
|
||||||
|
return $this->subscriber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return StatisticsClickEntity
|
||||||
|
*/
|
||||||
|
public function getClick() {
|
||||||
|
$this->safelyLoadToOneAssociation('click');
|
||||||
|
return $this->click;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Entities;
|
|||||||
|
|
||||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||||
|
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ class StatsNotificationEntity {
|
|||||||
use AutoincrementedIdTrait;
|
use AutoincrementedIdTrait;
|
||||||
use CreatedAtTrait;
|
use CreatedAtTrait;
|
||||||
use UpdatedAtTrait;
|
use UpdatedAtTrait;
|
||||||
|
use SafeToOneAssociationLoadTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
* @ORM\OneToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||||
@ -37,6 +39,7 @@ class StatsNotificationEntity {
|
|||||||
* @return NewsletterEntity
|
* @return NewsletterEntity
|
||||||
*/
|
*/
|
||||||
public function getNewsletter() {
|
public function getNewsletter() {
|
||||||
|
$this->safelyLoadToOneAssociation('newsletter');
|
||||||
return $this->newsletter;
|
return $this->newsletter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +47,7 @@ class StatsNotificationEntity {
|
|||||||
* @return ScheduledTaskEntity
|
* @return ScheduledTaskEntity
|
||||||
*/
|
*/
|
||||||
public function getTask() {
|
public function getTask() {
|
||||||
|
$this->safelyLoadToOneAssociation('task');
|
||||||
return $this->task;
|
return $this->task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user