scheduleRemove() public method

public scheduleRemove ( $document )
Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  *
  * Remove the previously persisted document and all its children from the tree
  *
  * Be aware of the PHPCR tree structure: this removes all nodes with a path under
  * the path of this object, even if there are no Parent / Child mappings
  * that make the relationship explicit.
  *
  * @param object $document
  *
  * @throws InvalidArgumentException if $document is not an object.
  */
 public function remove($document)
 {
     if (!is_object($document)) {
         throw new InvalidArgumentException('Parameter $document needs to be an object, ' . gettype($document) . ' given');
     }
     $this->errorIfClosed();
     $this->unitOfWork->scheduleRemove($document);
 }
Ejemplo n.º 2
0
 /**
  * Remove the previously persisted document and all its children from the tree
  *
  * Be aware of the PHPCR tree structure: this removes all nodes with a path under
  * the path of this object, even if there are no @Parent / @Child annotations
  * that make the relationship explicit.
  *
  * @param object $document
  */
 public function remove($document)
 {
     if (!is_object($document)) {
         throw new \InvalidArgumentException(gettype($document));
     }
     $this->errorIfClosed();
     $this->unitOfWork->scheduleRemove($document);
 }
Ejemplo n.º 3
0
 /**
  * @see https://github.com/doctrine/phpcr-odm/issues/637
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::computeSingleDocumentChangeSet
  */
 public function testComputeSingleDocumentChangeSetForRemovedDocument()
 {
     $object = new UoWUser();
     $object->username = "******";
     $object->id = '/somepath';
     $this->uow->scheduleRemove($object);
     // Should not throw "InvalidArgumentException: Document has to be managed for single computation"
     $this->uow->computeSingleDocumentChangeSet($object);
 }
Ejemplo n.º 4
0
 public function testSchedules()
 {
     $user1 = new CmsUser();
     $user1->username = '******';
     $address = new CmsAddress();
     $address->city = "Springfield";
     $address->zip = "12354";
     $address->country = "Germany";
     $user1->address = $address;
     // getScheduledInserts
     $this->uow->scheduleInsert($user1);
     $this->uow->computeChangeSets();
     $scheduledInserts = $this->uow->getScheduledInserts();
     $this->assertCount(2, $scheduledInserts);
     $this->assertEquals($user1, current($scheduledInserts));
     $this->assertEquals(32, strlen(key($scheduledInserts)), 'Size of key is 32 chars (oid)');
     $user1->username = '******';
     // getScheduledUpdates
     $this->uow->commit();
     $this->uow->scheduleInsert($user1);
     $this->uow->computeChangeSets();
     $scheduledUpdates = $this->uow->getScheduledUpdates();
     $this->assertCount(1, $scheduledUpdates);
     $this->assertEquals($user1, current($scheduledUpdates));
     $this->assertEquals(32, strlen(key($scheduledUpdates)), 'Size of key is 32 chars (oid)');
     // getScheduledRemovals
     $this->uow->scheduleRemove($user1);
     $scheduledRemovals = $this->uow->getScheduledRemovals();
     $this->assertCount(1, $scheduledRemovals);
     $this->assertEquals($user1, current($scheduledRemovals));
     $this->assertEquals(32, strlen(key($scheduledRemovals)), 'Size of key is 32 chars (oid)');
     // getScheduledMoves
     $this->uow->scheduleMove($user1, '/foobar');
     $scheduledMoves = $this->uow->getScheduledMoves();
     $this->assertCount(1, $scheduledMoves);
     $this->assertEquals(32, strlen(key($scheduledMoves)), 'Size of key is 32 chars (oid)');
     $this->assertEquals(array($user1, '/foobar'), current($scheduledMoves));
 }
Ejemplo n.º 5
0
 /**
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::scheduleRemove
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::scheduleInsert
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::doScheduleInsert
  */
 public function testScheduleInsertCancelsScheduleRemove()
 {
     $object = new UoWUser();
     $object->username = "******";
     $object->id = '/somepath';
     $this->uow->scheduleInsert($object);
     $this->uow->scheduleRemove($object);
     $method = new \ReflectionMethod($this->uow, 'getDocumentState');
     $method->setAccessible(true);
     $state = $method->invoke($this->uow, $object);
     $method->setAccessible(false);
     $this->assertEquals(UnitOfWork::STATE_REMOVED, $state);
     $this->uow->scheduleInsert($object);
     $method->setAccessible(true);
     $state = $method->invoke($this->uow, $object);
     $method->setAccessible(false);
     $this->assertEquals(UnitOfWork::STATE_MANAGED, $state);
 }
Ejemplo n.º 6
0
 /**
  * Remove the previously persisted document and all its children from the tree
  *
  * Be aware of the PHPCR tree structure: this removes all nodes with a path under
  * the path of this object, even if there are no @Parent / @Child annotations
  * that make the relationship explicit.
  *
  * @param object $object
  */
 public function remove($object)
 {
     $this->errorIfClosed();
     $this->unitOfWork->scheduleRemove($object);
 }