/** * Check if entity is in a valid state for operations. * * @param object $entity * * @return bool */ protected function isValidEntityState($entity) { $entityState = $this->uow->getEntityState($entity, UnitOfWork::STATE_NEW); if ($entityState === UnitOfWork::STATE_NEW) { return false; } // If Entity is scheduled for inclusion, it is not in this collection. // We can assure that because it would have return true before on array check return !($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($entity)); }
/** * @param object $entity * @param UnitOfWork $uow * * @return bool */ protected function isNewEntity($entity, UnitOfWork $uow) { $entityState = $uow->getEntityState($entity); return $entityState !== UnitOfWork::STATE_NEW && $entityState !== UnitOfWork::STATE_DETACHED && !$uow->isScheduledForInsert($entity); }
/** * Determines whether an entity instance is managed in this EntityManager. * * @param object $entity * * @return boolean TRUE if this EntityManager currently manages the given entity, FALSE otherwise. */ public function contains($entity) { return $this->unitOfWork->isScheduledForInsert($entity) || $this->unitOfWork->isInIdentityMap($entity) && !$this->unitOfWork->isScheduledForDelete($entity); }