mailpoet
/
vendor-prefixed
/
doctrine
/
orm
/
src
/
Persisters
/
Collection
/
AbstractCollectionPersister.php
AbstractCollectionPersister.php
9 months ago
CollectionPersister.php
9 months ago
ManyToManyPersister.php
9 months ago
OneToManyPersister.php
9 months ago
index.php
9 months ago
AbstractCollectionPersister.php
36 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Persisters\Collection; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Connection; |
| 6 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 7 | use MailPoetVendor\Doctrine\ORM\EntityManagerInterface; |
| 8 | use MailPoetVendor\Doctrine\ORM\Mapping\QuoteStrategy; |
| 9 | use MailPoetVendor\Doctrine\ORM\UnitOfWork; |
| 10 | abstract class AbstractCollectionPersister implements CollectionPersister |
| 11 | { |
| 12 | protected $em; |
| 13 | protected $conn; |
| 14 | protected $uow; |
| 15 | protected $platform; |
| 16 | protected $quoteStrategy; |
| 17 | public function __construct(EntityManagerInterface $em) |
| 18 | { |
| 19 | $this->em = $em; |
| 20 | $this->uow = $em->getUnitOfWork(); |
| 21 | $this->conn = $em->getConnection(); |
| 22 | $this->platform = $this->conn->getDatabasePlatform(); |
| 23 | $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); |
| 24 | } |
| 25 | protected function isValidEntityState($entity) |
| 26 | { |
| 27 | $entityState = $this->uow->getEntityState($entity, UnitOfWork::STATE_NEW); |
| 28 | if ($entityState === UnitOfWork::STATE_NEW) { |
| 29 | return \false; |
| 30 | } |
| 31 | // If Entity is scheduled for inclusion, it is not in this collection. |
| 32 | // We can assure that because it would have return true before on array check |
| 33 | return !($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($entity)); |
| 34 | } |
| 35 | } |
| 36 |