Use Doctrine references when saving links

This commit changes the code of the method
\MailPoet\Newsletter\Links\Links::save() to use Doctrine references
instead of full entities when getting a newsletter and sending queue
entities to save the related links.

We don't need the full entities here, and getting a full entity for the
sending queue was generating an error in the
testItLogsErrorWhenNewlyRenderedNewsletterBodyIsInvalid() integration
test (see the description of PR
https://github.com/mailpoet/mailpoet/pull/3784 for more details).

To be able to get the reference, it was necessary to add a helper method
called getReference() to \MailPoet\Doctrine\Repository.

[MAILPOET-3816]
This commit is contained in:
Rodrigo Primo
2021-11-10 08:58:55 -03:00
committed by Veljko V
parent ea3b38bc08
commit ae99fe3be2
2 changed files with 6 additions and 2 deletions

View File

@@ -103,6 +103,10 @@ abstract class Repository {
$this->entityManager->flush();
}
public function getReference($id) {
return $this->entityManager->getReference($this->getEntityClassName(), $id);
}
/**
* @param T $entity
*/