scheduleMove() публичный Метод

public scheduleMove ( $document, $targetPath )
Пример #1
0
 /**
  * Move the previously persisted document and all its children in the tree
  *
  * Note that this does not update the @Id fields of child documents and
  * neither fields with @Child/Children annotations. If you want to continue
  * working with the manager after a move, you are probably safest calling
  * DocumentManager::clear and re-loading the documents you need to use.
  *
  * @param object $document an already registered document
  * @param string $targetPath the target path including the nodename
  */
 public function move($document, $targetPath)
 {
     if (!is_object($document)) {
         throw new \InvalidArgumentException(gettype($document));
     }
     $this->errorIfClosed();
     $this->unitOfWork->scheduleMove($document, $targetPath);
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function move($document, $targetPath)
 {
     if (!is_object($document)) {
         throw new InvalidArgumentException('Parameter $document needs to be an object, ' . gettype($document) . ' given');
     }
     if (strpos($targetPath, '/') !== 0) {
         $targetPath = '/' . $targetPath;
     }
     $this->errorIfClosed();
     $this->unitOfWork->scheduleMove($document, $targetPath);
 }
Пример #3
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));
 }
Пример #4
0
 /**
  * Move the previously persisted document and all its children in the tree
  *
  * Note that this does not update the @Id fields of child documents and
  * neither fields with @Child/Children annotations. If you want to continue
  * working with the manager after a move, you are probably safest calling
  * DocumentManager::clear and re-loading the documents you need to use.
  *
  * @param object $object
  * @param string $targetPath
  */
 public function move($object, $targetPath)
 {
     $this->errorIfClosed();
     $this->unitOfWork->scheduleMove($object, $targetPath);
 }