Apply safe to load association trait to all toOne associations

[MAILPOET-2818]
This commit is contained in:
Rostislav Wolny
2020-04-06 15:15:36 +02:00
committed by Veljko V
parent 217b9194db
commit 63a2bed8bf
9 changed files with 114 additions and 9 deletions

View File

@@ -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;
}