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\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\Common\Collections\ArrayCollection;
|
||||
use MailPoetVendor\Doctrine\Common\Collections\Criteria;
|
||||
use MailPoetVendor\Doctrine\ORM\EntityNotFoundException;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
@ -39,6 +39,7 @@ class NewsletterEntity {
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use DeletedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
@ -342,15 +343,9 @@ class NewsletterEntity {
|
||||
* @return NewsletterEntity|null
|
||||
*/
|
||||
public function getParent() {
|
||||
try {
|
||||
if ($this->parent && $this->parent->getId()) {
|
||||
$this->safelyLoadToOneAssociation('parent');
|
||||
return $this->parent;
|
||||
}
|
||||
} catch (EntityNotFoundException $enf) {
|
||||
$this->setParent(null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NewsletterEntity|null $parent
|
||||
|
@ -4,6 +4,7 @@ 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\Common\Collections\ArrayCollection;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
@ -16,6 +17,7 @@ class NewsletterLinkEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||
@ -56,6 +58,7 @@ class NewsletterLinkEntity {
|
||||
* @return NewsletterEntity|null
|
||||
*/
|
||||
public function getNewsletter() {
|
||||
$this->safelyLoadToOneAssociation('newsletter');
|
||||
return $this->newsletter;
|
||||
}
|
||||
|
||||
@ -63,6 +66,7 @@ class NewsletterLinkEntity {
|
||||
* @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\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@ -15,6 +16,8 @@ class NewsletterOptionEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
@ -52,6 +55,7 @@ class NewsletterOptionEntity {
|
||||
* @return NewsletterEntity
|
||||
*/
|
||||
public function getNewsletter() {
|
||||
$this->safelyLoadToOneAssociation('newsletter');
|
||||
return $this->newsletter;
|
||||
}
|
||||
|
||||
@ -66,6 +70,7 @@ class NewsletterOptionEntity {
|
||||
* @return NewsletterOptionFieldEntity
|
||||
*/
|
||||
public function getOptionField() {
|
||||
$this->safelyLoadToOneAssociation('optionField');
|
||||
return $this->optionField;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ namespace MailPoet\Entities;
|
||||
use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
|
||||
@ -25,6 +26,7 @@ class SendingQueueEntity {
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use DeletedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json_or_serialized")
|
||||
@ -183,6 +185,7 @@ class SendingQueueEntity {
|
||||
* @return ScheduledTaskEntity
|
||||
*/
|
||||
public function getTask() {
|
||||
$this->safelyLoadToOneAssociation('task');
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
@ -194,6 +197,7 @@ class SendingQueueEntity {
|
||||
* @return NewsletterEntity
|
||||
*/
|
||||
public function getNewsletter() {
|
||||
$this->safelyLoadToOneAssociation('newsletter');
|
||||
return $this->newsletter;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ 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;
|
||||
|
||||
@ -15,6 +16,7 @@ class StatisticsClickEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||
@ -48,4 +50,27 @@ class StatisticsClickEntity {
|
||||
*/
|
||||
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\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@ -13,6 +14,7 @@ use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
class StatisticsOpenEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||
@ -34,4 +36,19 @@ class StatisticsOpenEntity {
|
||||
*/
|
||||
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\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@ -13,6 +14,7 @@ use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
class StatisticsUnsubscribeEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||
@ -34,4 +36,19 @@ class StatisticsUnsubscribeEntity {
|
||||
*/
|
||||
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\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@ -15,6 +16,7 @@ class StatisticsWooCommercePurchaseEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||
@ -70,4 +72,36 @@ class StatisticsWooCommercePurchaseEntity {
|
||||
$this->orderCurrency = $orderCurrency;
|
||||
$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\CreatedAtTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\SafeToOneAssociationLoadTrait;
|
||||
use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@ -15,6 +16,7 @@ class StatsNotificationEntity {
|
||||
use AutoincrementedIdTrait;
|
||||
use CreatedAtTrait;
|
||||
use UpdatedAtTrait;
|
||||
use SafeToOneAssociationLoadTrait;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="MailPoet\Entities\NewsletterEntity")
|
||||
@ -37,6 +39,7 @@ class StatsNotificationEntity {
|
||||
* @return NewsletterEntity
|
||||
*/
|
||||
public function getNewsletter() {
|
||||
$this->safelyLoadToOneAssociation('newsletter');
|
||||
return $this->newsletter;
|
||||
}
|
||||
|
||||
@ -44,6 +47,7 @@ class StatsNotificationEntity {
|
||||
* @return ScheduledTaskEntity
|
||||
*/
|
||||
public function getTask() {
|
||||
$this->safelyLoadToOneAssociation('task');
|
||||
return $this->task;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user