当前位置: 首页>>代码示例>>PHP>>正文


PHP DocumentManager::move方法代码示例

本文整理汇总了PHP中Doctrine\ODM\PHPCR\DocumentManager::move方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::move方法的具体用法?PHP DocumentManager::move怎么用?PHP DocumentManager::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ODM\PHPCR\DocumentManager的用法示例。


在下文中一共展示了DocumentManager::move方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDetachWithMove

 /**
  * @expectedException \Doctrine\ODM\PHPCR\Exception\InvalidArgumentException
  */
 public function testDetachWithMove()
 {
     $user = $this->dm->find($this->type, '/functional/lsmith');
     $user->username = "new-name";
     $this->dm->detach($user);
     $this->dm->move($user, '/functional/user2');
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:10,代码来源:DetachTest.php

示例2: testComputingBetweenEvents

 public function testComputingBetweenEvents()
 {
     $this->dm->getEventManager()->addEventListener(array(Event::prePersist, Event::postPersist, Event::preUpdate, Event::postUpdate, Event::preMove, Event::postMove), $this->listener);
     // Create initial user
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->name = 'mdekrijger';
     $user->username = 'mdekrijger';
     $user->status = 'active';
     // In prepersist the name will be changed
     // In postpersist the username will be changed
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     // Post persist data is not saved to document, so check before reloading document
     $this->assertTrue($user->username == 'postpersist');
     // Be sure that document is really saved by refetching it from ODM
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $user->id);
     $this->assertEquals('prepersist', $user->name);
     $this->assertEquals('active', $user->status);
     // Change document
     // In preupdate the name will be changed
     // In postupdate the username will be changed
     $user->status = 'changed';
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     // Post persist data is not saved to document, so check before reloading document
     $this->assertEquals('postupdate', $user->username);
     // Be sure that document is really saved by refetching it from ODM
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $user->id);
     $this->assertEquals('preupdate', $user->name);
     $this->assertEquals('changed', $user->status);
     // Move from /functional/preudpate to /functional/moved
     $targetPath = '/functional/moved';
     $this->dm->move($user, $targetPath);
     $this->dm->flush();
     // we overwrote the name and username fields during the move event, so the object changed
     $this->assertEquals('premove', $user->name);
     $this->assertEquals('premove-postmove', $user->username);
     $this->dm->clear();
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $targetPath);
     // the document was moved but the only changes applied in preUpdate are persisted,
     // pre/postMove changes are not persisted in that flush
     $this->assertEquals('preupdate', $user->name);
     $this->assertTrue($this->listener->preMove);
     // Clean up
     $this->dm->remove($user);
     $this->dm->flush();
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:49,代码来源:EventComputingTest.php

示例3: testReorderAfterMove

 public function testReorderAfterMove()
 {
     $parent = $this->dm->find(null, '/functional/source');
     $this->dm->move($parent, '/functional/target/new');
     $this->dm->reorder($parent, 'first', 'second', false);
     $this->dm->flush();
     $parent = $this->dm->find(null, '/functional/target/new');
     $this->assertSame(array('second', 'first', 'third', 'fourth'), $this->getChildrenNames($parent->getChildren()));
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:9,代码来源:ReorderTest.php

示例4: testRequiredClassesInvalidUpdate

 /**
  * @expectedException Doctrine\ODM\PHPCR\Exception\OutOfBoundsException
  * @expectedExceptionMessage Document "Doctrine\Tests\Models\CMS\CmsArticleFolder" does not allow children of type "Doctrine\Tests\Models\CMS\CmsGroup". Allowed child classes "Doctrine\Tests\Models\CMS\CmsArticle"
  */
 public function testRequiredClassesInvalidUpdate()
 {
     $articleFolder = new CmsArticleFolder();
     $articleFolder->id = '/functional/articles';
     $article = new CmsGroup();
     $article->id = '/functional/address';
     $article->name = 'invalid-child';
     $this->dm->persist($articleFolder);
     $this->dm->persist($article);
     $this->dm->flush();
     $this->dm->move($article, '/functional/articles/address');
     $this->dm->flush();
 }
开发者ID:doctrine,项目名称:phpcr-odm,代码行数:17,代码来源:UnitOfWorkTest.php

示例5: _move

 /**
  * Move file into another parent dir or rename file.
  * Return new file path or false.
  *
  * @param  string      $source    source file path
  * @param  string      $targetDir target dir path
  * @param  string      $name      file name
  * @return string|bool
  * @author Dmitry (dio) Levashov
  **/
 protected function _move($source, $targetDir, $name)
 {
     $filename = $this->_joinPath($targetDir, $name);
     $sourceDir = $this->_dirname($source);
     try {
         $doc = $this->dm->find(null, $source);
         // move
         $this->dm->move($doc, $filename);
         $this->dm->flush();
     } catch (\Exception $e) {
         return false;
     }
     return $filename;
 }
开发者ID:Aerendir,项目名称:MediaBundle,代码行数:24,代码来源:PhpcrDriver.php

示例6: testDepth

 public function testDepth()
 {
     $object = new DepthMappingObject();
     $object->id = '/functional/test';
     $this->dm->persist($object);
     $this->dm->flush();
     $this->dm->clear();
     $object = $this->dm->find(null, '/functional/test');
     $this->assertEquals(2, $object->depth);
     NodeHelper::createPath($this->dm->getPhpcrSession(), '/functional/newtest/foobar');
     $this->dm->move($object, '/functional/newtest/foobar/test');
     $this->dm->flush();
     $this->assertEquals(4, $object->depth);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:14,代码来源:BasicCrudTest.php

示例7: testMoveChildren

 /**
  * Move a child out of the children collection
  */
 public function testMoveChildren()
 {
     $this->createChildren();
     $parent = $this->dm->find($this->type, '/functional/parent');
     $child = $parent->allChildren->first();
     $this->dm->move($child, '/functional/elsewhere');
     $this->dm->flush();
     $this->dm->clear();
     $child = $this->dm->find(null, '/functional/elsewhere');
     $this->assertInstanceOf($this->type, $child);
     $parent = $this->dm->find(null, '/functional/parent');
     $this->assertInstanceOf($this->type, $parent);
     $this->assertCount(3, $parent->allChildren);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:17,代码来源:ChildrenTest.php

示例8: move

 /**
  * {@inheritDoc}
  */
 public function move($movedPath, $targetPath)
 {
     $resultingPath = $targetPath . '/' . basename($movedPath);
     $document = $this->dm->find(null, $movedPath);
     if (null === $document) {
         return "No document found at {$movedPath}";
     }
     $this->dm->move($document, $resultingPath);
     $this->dm->flush();
     $admin = $this->getAdmin($document);
     if (null !== $admin) {
         $id = $admin->getNormalizedIdentifier($document);
         $urlSafeId = $admin->getUrlsafeIdentifier($document);
     } else {
         $id = $this->defaultModelManager->getNormalizedIdentifier($document);
         $urlSafeId = $this->defaultModelManager->getUrlsafeIdentifier($document);
     }
     return array('id' => $id, 'url_safe_id' => $urlSafeId);
 }
开发者ID:viral810,项目名称:ngSimpleCMS,代码行数:22,代码来源:PhpcrOdmTree.php

示例9: testMoveUpdateFields

 public function testMoveUpdateFields()
 {
     $this->dm->clear();
     $user1 = $this->dm->find($this->type, '/functional/lsmith');
     $this->assertNotNull($user1, 'User must exist');
     $user2 = new CmsTeamUser();
     $user2->username = 'jwage';
     $user2->parent = $user1;
     $user3 = new CmsTeamUser();
     $user3->username = 'beberlei';
     $user3->parent = $user2;
     $this->dm->persist($user3);
     $this->dm->flush();
     // property is updated after flush
     $this->assertEquals('beberlei', $user3->nodename);
     $this->assertSame($user2, $user3->parent);
     $this->dm->move($user3, '/functional/lsmith/user');
     $this->dm->flush();
     $this->assertEquals('user', $user3->nodename);
     $this->assertSame($user1, $user3->parent);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:21,代码来源:MoveTest.php

示例10: testTriggerEvents

 public function testTriggerEvents()
 {
     $this->dm->getEventManager()->addEventListener(array(Event::prePersist, Event::postPersist, Event::preUpdate, Event::postUpdate, Event::preRemove, Event::postRemove, Event::onFlush, Event::postFlush, Event::preFlush, Event::preMove, Event::postMove, Event::endFlush), $this->listener);
     $page = new CmsPage();
     $page->title = "my-page";
     $page->content = "long story";
     $this->dm->persist($page);
     $this->assertTrue($this->listener->pagePrePersist);
     $this->assertFalse($this->listener->itemPrePersist);
     $this->assertFalse($this->listener->postFlush);
     $this->assertFalse($this->listener->endFlush);
     $this->assertFalse($this->listener->preFlush);
     $this->dm->flush();
     $this->assertTrue($this->listener->onFlush);
     $this->assertTrue($this->listener->postFlush);
     $this->assertTrue($this->listener->endFlush);
     $this->assertTrue($this->listener->preFlush);
     $this->assertFalse($this->listener->preUpdate);
     $this->assertFalse($this->listener->postUpdate);
     $this->assertTrue($this->listener->pagePostPersist);
     $this->assertFalse($this->listener->itemPostPersist);
     $this->assertFalse($this->listener->pagePreRemove);
     $this->assertFalse($this->listener->pagePostRemove);
     $this->assertFalse($this->listener->itemPreRemove);
     $this->assertFalse($this->listener->pagePreMove);
     $this->assertFalse($this->listener->pagePostMove);
     $this->assertFalse($this->listener->itemPreMove);
     $this->assertFalse($this->listener->itemPostMove);
     $this->dm->move($page, '/functional/moved-' . $page->title);
     $this->assertFalse($this->listener->pagePreMove);
     $this->assertFalse($this->listener->pagePostMove);
     $this->dm->flush();
     $this->assertTrue($this->listener->pagePreMove);
     $this->assertTrue($this->listener->pagePostMove);
     $this->assertFalse($this->listener->itemPreMove);
     $this->assertFalse($this->listener->itemPostMove);
     $this->dm->flush();
     $item = new CmsItem();
     $item->name = "my-item";
     $item->documentTarget = $page;
     $page->content = "short story";
     $this->dm->persist($item);
     $page->addItem($item);
     $this->dm->flush();
     $this->assertTrue($this->listener->preUpdate);
     $this->assertTrue($this->listener->itemPrePersist);
     $this->assertTrue($this->listener->postUpdate);
     $this->assertTrue($this->listener->itemPostPersist);
     $this->assertEquals('long story is now short story', $page->content);
     $pageId = $this->dm->getUnitOfWork()->getDocumentId($page);
     $itemId = $this->dm->getUnitOfWork()->getDocumentId($item);
     $this->dm->clear();
     $page = $this->dm->find(null, $pageId);
     $item = $this->dm->find(null, $itemId);
     $this->assertEquals('long story is now short story', $page->content);
     $this->dm->remove($item);
     $this->dm->remove($page);
     $this->assertTrue($this->listener->pagePreRemove);
     $this->assertTrue($this->listener->itemPreRemove);
     $this->assertFalse($this->listener->pagePostRemove);
     $this->assertFalse($this->listener->itemPostRemove);
     $this->assertFalse($this->dm->contains($page));
     $this->assertFalse($this->dm->contains($item));
     $this->dm->flush();
     $this->assertFalse($this->dm->contains($page));
     $this->assertFalse($this->dm->contains($item));
     $this->assertTrue($this->listener->pagePostRemove);
     $this->assertTrue($this->listener->itemPostRemove);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:69,代码来源:EventManagerTest.php


注:本文中的Doctrine\ODM\PHPCR\DocumentManager::move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。