Gets the state of a document with regard to the current unit of work.
public getDocumentState ( object $document, integer | null $assume = null ) : integer | ||
$document | object | |
$assume | integer | null | The state to assume if the state is not yet known (not MANAGED or REMOVED). This parameter can be set to improve performance of document state detection by potentially avoiding a database lookup if the distinction between NEW and DETACHED is either known or does not matter for the caller of the method. |
Résultat | integer | The document state. |
function it_schedules_owning_document_for_update_when_setting_element_by_key_in_the_collection(MongoDBODMUnitOfWork $uow, DocumentStub $document, ObjectRepository $repository, ClassMetadata $classMetadata, EntityStub $entity4, EntityStub $entity8, EntityStub $entity15, EntityStub $newEntity) { $classMetadata->getIdentifier()->willReturn(['id']); $repository->findBy(['id' => [4, 8, 15]])->willReturn([$entity4, $entity8, $entity15]); $uow->getDocumentState($document)->willReturn(MongoDBODMUnitOfWork::STATE_MANAGED); $uow->isScheduledForUpdate($document)->willReturn(false); $uow->scheduleForUpdate($document)->shouldBeCalled(); $this->setOwner($document); $this->set(2, $newEntity); }