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


PHP DocumentManager::remove方法代码示例

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


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

示例1: testMergeRemovedDocument

 public function testMergeRemovedDocument()
 {
     $user = new CmsUser();
     $user->username = "beberlei";
     $user->name = "Benjamin";
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->remove($user);
     $this->setExpectedException('\\Doctrine\\ODM\\PHPCR\\Exception\\InvalidArgumentException', "Removed document detected during merge at '/functional/beberlei'. Cannot merge with a removed document.");
     $this->dm->merge($user);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:11,代码来源:MergeTest.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: testDetachWithRemove

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

示例4: testRemove3

 /**
  * Remove the parent node of multiple child level
  */
 public function testRemove3()
 {
     $parent = new ChildTestObj();
     $parent->name = 'Parent';
     $parent->id = '/functional/childtest';
     // Lv1
     $childLv1 = new ChildReferenceableTestObj();
     $childLv1->name = 'Child-Lv1';
     $parent->child = $childLv1;
     // Lv2
     $childLv2 = new ChildChildTestObj();
     $childLv2->name = 'Child-Lv2';
     $childLv1->aChild = $childLv2;
     $this->dm->persist($parent);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find($this->type, '/functional/childtest');
     $this->assertTrue($this->node->hasNode('childtest'));
     $this->assertTrue($this->node->getNode('childtest')->hasNode('test'));
     $this->assertTrue($this->node->getNode('childtest')->getNode('test')->hasNode('test'));
     $this->dm->remove($parent);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find($this->type, '/functional/childtest');
     $this->assertNull($parent);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:29,代码来源:ChildTest.php

示例5: testRemoveAndInsertBeforeFlush

 /**
  * @expectedException \Doctrine\ODM\PHPCR\Exception\InvalidArgumentException
  */
 public function testRemoveAndInsertBeforeFlush()
 {
     $this->dm->clear();
     $user = $this->dm->find($this->type, '/functional/user');
     $this->assertNotNull($user, 'User must exist');
     $this->dm->remove($user);
     $user = new User2();
     $user->username = "test";
     $user->id = '/functional/user';
     $this->dm->persist($user);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:14,代码来源:BasicCrudTest.php

示例6: testRemoveChildParent

 public function testRemoveChildParent()
 {
     $this->createChildren();
     $parent = $this->dm->find($this->type, '/functional/parent');
     $this->assertCount(4, $parent->allChildren);
     $this->dm->remove($parent);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find($this->type, '/functional/parent');
     $this->assertNull($parent);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:11,代码来源:ChildrenTest.php

示例7: _unlink

 /**
  * Remove file
  *
  * @param  string $path file path
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function _unlink($path)
 {
     if ($doc = $this->dm->find(null, $path)) {
         try {
             $this->dm->remove($doc);
             $this->dm->flush();
             return true;
         } catch (\Exception $e) {
             return false;
         }
     }
     return false;
 }
开发者ID:Aerendir,项目名称:MediaBundle,代码行数:20,代码来源:PhpcrDriver.php

示例8: testRemoveThenMove

 public function testRemoveThenMove()
 {
     $this->dm->clear();
     $user = $this->dm->find($this->type, '/functional/lsmith');
     $this->assertNotNull($user, 'User must exist');
     $this->dm->remove($user);
     $this->dm->move($user, '/functional/user2');
     $this->dm->flush();
     $user = $this->dm->find($this->type, '/functional/user2');
     $this->assertNotNull($user, 'User must exist');
     $user = $this->dm->find($this->type, '/functional/lsmith');
     $this->assertNull($user, 'User must be null after deletion');
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:13,代码来源:MoveTest.php

示例9: testDeleteByRef

 public function testDeleteByRef()
 {
     $referrerTestObj = new ReferrerTestObj();
     $referrerRefTestObj = new ReferrerRefTestObj();
     $referrerTestObj->id = "/functional/referrerTestObj";
     $referrerTestObj->name = 'referrer';
     $referrerRefTestObj->id = "/functional/referrerRefTestObj";
     $referrerTestObj->reference = $referrerRefTestObj;
     $this->dm->persist($referrerTestObj);
     $this->dm->flush();
     $this->dm->clear();
     $reference = $this->dm->find(null, "/functional/referrerRefTestObj");
     $this->dm->remove($reference->referrers[0]);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertCount(0, $this->dm->find(null, "/functional/referrerRefTestObj")->referrers);
     $this->assertFalse($this->session->getNode("/functional")->hasNode("referrerTestObj"));
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:18,代码来源:ReferrerTest.php

示例10: batchDelete

 /**
  * {@inheritDoc}
  *
  * @throws ModelManagerException if anything goes wrong during query execution.
  */
 public function batchDelete($class, ProxyQueryInterface $queryProxy)
 {
     try {
         $i = 0;
         $res = $queryProxy->execute();
         foreach ($res as $object) {
             $this->dm->remove($object);
             if (++$i % 20 == 0) {
                 $this->dm->flush();
                 $this->dm->clear();
             }
         }
         $this->dm->flush();
         $this->dm->clear();
     } catch (\Exception $e) {
         throw new ModelManagerException('', 0, $e);
     }
 }
开发者ID:Aaike,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:23,代码来源:ModelManager.php

示例11: testFindVersionByNameWithReference

 public function testFindVersionByNameWithReference()
 {
     $doc = $this->dm->find($this->typeVersion, '/functional/versionTestObjWithReference');
     $this->dm->checkpoint($doc);
     // Create a new version 1.0
     // Delete the reference in the doc, persist and checkpoint the doc
     $doc->reference = null;
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->dm->checkpoint($doc);
     // Create a new version 1.1
     // Remove the reference obj
     $referenceDoc = $this->dm->find($this->typeReference, '/functional/referenceTestObj');
     $this->dm->remove($referenceDoc);
     $this->dm->flush();
     $this->dm->clear();
     $frozenDocument = $this->dm->findVersionByName($this->typeVersion, '/functional/versionTestObjWithReference', '1.0');
     $this->assertNull($frozenDocument->reference);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:19,代码来源:VersioningTestAbstract.php

示例12: testRemove

 public function testRemove()
 {
     $this->dm->persist($this->doc);
     $this->dm->bindTranslation($this->doc, 'en');
     $this->dm->bindTranslation($this->doc, 'fr');
     $this->dm->flush();
     $this->dm->remove($this->doc);
     $this->dm->flush();
     $this->dm->clear();
     $this->doc = $this->dm->find($this->class, '/functional/' . $this->testNodeName);
     $this->assertNull($this->doc, 'Document must be null after deletion');
     $this->doc = new Article();
     $this->doc->id = '/functional/' . $this->testNodeName;
     $this->doc->author = 'John Doe';
     $this->doc->topic = 'Some interesting subject';
     $this->doc->setText('Lorem ipsum...');
     $this->dm->persist($this->doc);
     $this->dm->bindTranslation($this->doc, 'en');
     $this->dm->flush();
     $locales = $this->dm->getLocalesFor($this->doc);
     $this->assertEquals(array('en'), $locales, 'Removing a document must remove all translations');
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:22,代码来源:DocumentManagerTest.php

示例13: testManyCascadeWithParentDelete

 public function testManyCascadeWithParentDelete()
 {
     $refManyTestObjForCascade = new RefManyWithParentTestObjForCascade();
     $refManyTestObjForCascade->id = "/functional/refManyWithParentTestObjForCascade";
     $references = array();
     for ($i = 0; $i < 3; $i++) {
         $newRefCascadeManyTestObj = new ParentTestObj();
         $newRefCascadeManyTestObj->nodename = "ref{$i}";
         $newRefCascadeManyTestObj->name = "refCascadeWithParentManyTestObj{$i}";
         $references[] = $newRefCascadeManyTestObj;
     }
     $refManyTestObjForCascade->setReferences($references);
     $this->dm->persist($refManyTestObjForCascade);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->session->getNode("/functional")->hasNode("refManyWithParentTestObjForCascade"));
     for ($i = 0; $i < 3; $i++) {
         $this->assertTrue($this->session->getNode("/functional/refManyWithParentTestObjForCascade")->hasNode("ref{$i}"));
     }
     $referrer = $this->dm->find($this->referrerManyWithParentForCascadeType, '/functional/refManyWithParentTestObjForCascade');
     $this->dm->remove($referrer);
     $this->dm->flush();
     $this->assertFalse($this->session->getNode("/functional")->hasNode("refManyWithParentTestObjForCascade"));
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:24,代码来源:ReferenceTest.php

示例14: testReorderAfterRemove

 /**
  * @expectedException \Doctrine\ODM\PHPCR\Exception\InvalidArgumentException
  */
 public function testReorderAfterRemove()
 {
     $parent = $this->dm->find(null, '/functional/source');
     $this->dm->remove($parent);
     $this->dm->reorder($parent, 'first', 'second', false);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:9,代码来源:ReorderTest.php

示例15: 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::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。