Check parent exists before returning it
[MAILPOET-2350]
This commit is contained in:
committed by
Jack Kitterhing
parent
025110af5d
commit
2b51b2f209
@@ -9,6 +9,7 @@ use MailPoet\Doctrine\EntityTraits\DeletedAtTrait;
|
|||||||
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\Collection;
|
use MailPoetVendor\Doctrine\Common\Collections\Collection;
|
||||||
|
use MailPoetVendor\Doctrine\ORM\EntityNotFoundException;
|
||||||
use MailPoetVendor\Doctrine\ORM\Mapping\Column;
|
use MailPoetVendor\Doctrine\ORM\Mapping\Column;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -310,8 +311,15 @@ class NewsletterEntity {
|
|||||||
* @return NewsletterEntity|null
|
* @return NewsletterEntity|null
|
||||||
*/
|
*/
|
||||||
function getParent() {
|
function getParent() {
|
||||||
|
try {
|
||||||
|
if ($this->parent && $this->parent->getId()) {
|
||||||
return $this->parent;
|
return $this->parent;
|
||||||
}
|
}
|
||||||
|
} catch (EntityNotFoundException $enf) {
|
||||||
|
$this->setParent(null);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param NewsletterEntity|null $parent
|
* @param NewsletterEntity|null $parent
|
||||||
|
Reference in New Issue
Block a user