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


PHP DocumentManager::find方法代码示例

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


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

示例1: testReferenceOneDifferentTargetDocuments

 public function testReferenceOneDifferentTargetDocuments()
 {
     $ref1 = new MODEL\RefType1TestObj();
     $ref1->id = '/functional/ref1';
     $ref1->name = 'Ref1';
     $ref2 = new MODEL\RefType2TestObj();
     $ref2->id = '/functional/ref2';
     $ref2->name = 'Ref2';
     $this->dm->persist($ref1);
     $this->dm->persist($ref2);
     $referer1 = new ReferenceOneObj();
     $referer1->id = '/functional/referer1';
     $referer1->reference = $ref1;
     $this->dm->persist($referer1);
     $referer2 = new ReferenceOneObj();
     $referer2->id = '/functional/referer2';
     $referer2->reference = $ref2;
     $this->dm->persist($referer2);
     $this->dm->flush();
     $this->dm->clear();
     $referer = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ReferenceOneObj', '/functional/referer1');
     $this->assertTrue($referer->reference instanceof MODEL\RefType1TestObj);
     $referer = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ReferenceOneObj', '/functional/referer2');
     $this->assertTrue($referer->reference instanceof MODEL\RefType2TestObj);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:25,代码来源:TargetDocumentTest.php

示例2: setUp

 public function setUp()
 {
     $this->db('PHPCR')->loadFixtures(array('Doctrine\\Bundle\\PHPCRBundle\\Tests\\Resources\\DataFixtures\\PHPCR\\LoadData'));
     $this->dm = $this->db('PHPCR')->getOm();
     $this->document = $this->dm->find(null, '/test/doc');
     $this->assertNotNull($this->document, 'fixture loading not working');
     $this->referrer = $this->dm->find(null, '/test/ref');
     $this->assertNotNull($this->referrer, 'fixture loading not working');
 }
开发者ID:pkdevbox,项目名称:DoctrinePHPCRBundle,代码行数:9,代码来源:PHPCRTypeGuesserTest.php

示例3: testFind

 public function testFind()
 {
     $doc = $this->dm->find($this->type, '/functional/thename');
     $this->assertInstanceOf($this->type, $doc);
     $this->assertEquals('/functional/thename', $doc->id);
     $this->assertEquals('thename', $doc->nodename);
     $this->assertNotNull($doc->parent);
     $this->assertEquals('/functional', $doc->parent->getId());
     return $doc;
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:10,代码来源:TranslationHierarchyTest.php

示例4: testPropertyname

 public function testPropertyname()
 {
     $doc = new PropertyTestObj();
     $doc->id = '/functional/p';
     $doc->string = 'astring';
     $doc->long = 123;
     $doc->int = 321;
     $doc->decimal = '343';
     $doc->double = 3.14;
     $doc->float = 2.8;
     $date = new \DateTime();
     $doc->date = $date;
     $doc->boolean = true;
     $doc->name = 'aname';
     $doc->path = '../';
     $doc->uri = 'http://cmf.symfony.com:8080/about.html#there';
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->node->getNode('p')->hasProperty('string'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('long'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('int'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('decimal'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('double'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('float'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('date'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('boolean'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('name'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('path'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('uri'));
     $doc = $this->dm->find($this->type, '/functional/p');
     $this->assertNotNull($doc->string);
     $this->assertEquals('astring', $doc->string);
     $this->assertNotNull($doc->long);
     $this->assertEquals(123, $doc->long);
     $this->assertNotNull($doc->int);
     $this->assertEquals(321, $doc->int);
     $this->assertNotNull($doc->decimal);
     $this->assertEquals('343', $doc->decimal);
     $this->assertNotNull($doc->double);
     $this->assertEquals(3.14, $doc->double);
     $this->assertNotNull($doc->float);
     $this->assertEquals(2.8, $doc->float);
     $this->assertNotNull($doc->date);
     $this->assertEquals($date->getTimestamp(), $doc->date->getTimestamp());
     $this->assertNotNull($doc->boolean);
     $this->assertEquals(true, $doc->boolean);
     $this->assertNotNull($doc->name);
     $this->assertEquals('aname', $doc->name);
     $this->assertNotNull($doc->path);
     $this->assertEquals('../', $doc->path);
     $this->assertNotNull($doc->uri);
     $this->assertEquals('http://cmf.symfony.com:8080/about.html#there', $doc->uri);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:54,代码来源:PropertyTest.php

示例5: testCreatedDate

 public function testCreatedDate()
 {
     $parent = new FileTestObj();
     $parent->file = new File();
     $parent->id = '/functional/filetest';
     $parent->file->setFileContentFromFilesystem(dirname(__FILE__) . '/_files/foo.txt');
     $this->dm->persist($parent);
     $this->dm->flush();
     $this->dm->clear();
     $file = $this->dm->find('Doctrine\\ODM\\PHPCR\\Document\\File', '/functional/filetest/file');
     $this->assertNotNull($file);
     $this->assertNotNull($file->getCreated());
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:13,代码来源:FileTest.php

示例6: testReorderChildren

 public function testReorderChildren()
 {
     $this->testModifyChildren();
     try {
         $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
         $this->assertCount(2, $parent->allChildren);
         $data = array('child-g' => $parent->allChildren->last(), 'child-f' => $parent->allChildren->first());
         $parent->allChildren = new ArrayCollection($data);
         $this->dm->flush();
         $this->dm->clear();
         $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
         $this->assertCount(count($data), $parent->allChildren);
         $this->assertEquals(array_keys($data), $parent->allChildren->getKeys());
         $child1 = new ChildrenTestObj();
         $child1->name = 'Child H';
         $child2 = new ChildrenTestObj();
         $child2->name = 'Child I';
         $child3 = new ChildrenTestObj();
         $child3->name = 'Child J';
         $data = array('child-i' => $child2, 'child-h' => $child1, 'child-f' => $parent->allChildren->last(), 'child-g' => $parent->allChildren->first(), 'child-j' => $child3);
         $parent->allChildren = new ArrayCollection($data);
         $this->dm->flush();
         $this->dm->clear();
         $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
         $this->assertCount(count($data), $parent->allChildren);
         $this->assertEquals(array_keys($data), $parent->allChildren->getKeys());
     } catch (UnsupportedRepositoryOperationException $e) {
         $this->markTestSkipped('Reordering of children not supported');
     }
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:30,代码来源:ChildrenTest.php

示例7: testDetachWithRemove

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

示例8: testAddRemoveAttachment

 public function testAddRemoveAttachment()
 {
     $fh = fopen(__DIR__ . '/_files/logo.jpg', 'r');
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'user_with_attachment');
     $user->attachments['logo.jpg'] = Attachment::createFromBinaryData($fh, 'image/jpeg');
     $this->dm->flush();
     $this->dm->clear();
     // dont re-use identity map
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'user_with_attachment');
     unset($user->attachments['foo.txt']);
     $this->dm->flush();
     $this->dm->clear();
     // dont re-use identity map
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'user_with_attachment');
     $this->assertArrayHasKey('logo.jpg', $user->attachments);
     $this->assertArrayNotHasKey('foo.txt', $user->attachments);
 }
开发者ID:doctrine,项目名称:couchdb-odm,代码行数:17,代码来源:AttachmentTest.php

示例9: testPropertyname

 public function testPropertyname()
 {
     $doc = new TestObj();
     $doc->id = '/functional/pn';
     $doc->name = 'Testname';
     $doc->othername = 'Testothername';
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->node->getNode('pn')->hasProperty('name'));
     $this->assertTrue($this->node->getNode('pn')->hasProperty('myname'));
     $doc = $this->dm->find($this->type, '/functional/pn');
     $this->assertNotNull($doc->name);
     $this->assertEquals('Testname', $doc->name);
     $this->assertNotNull($doc->othername);
     $this->assertEquals('Testothername', $doc->othername);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:17,代码来源:PropertyNameTest.php

示例10: testProxyForChildIsUsed

 function testProxyForChildIsUsed()
 {
     $doc = $this->dm->find($this->type, '/functional/thename');
     $doc->child = new NameDoc();
     $this->dm->flush();
     $this->dm->clear();
     $doc = $this->dm->find($this->type, '/functional/thename');
     $this->assertTrue($doc->child instanceof Proxy);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:9,代码来源:HierarchyTest.php

示例11: testChildOfRoot

 function testChildOfRoot()
 {
     $root = $this->dm->find(null, '/');
     $child = new NameDoc();
     $child->parent = $root;
     $child->nodename = 'childOfRoot';
     $this->dm->persist($child);
     $this->dm->flush();
     $this->assertEquals('/childOfRoot', $child->id);
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:10,代码来源:HierarchyTest.php

示例12: testRemoveChildParent

 public function testRemoveChildParent()
 {
     $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
     $this->assertCount(4, $parent->allChildren);
     $this->dm->remove($parent);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
     $this->assertNull($parent);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:10,代码来源:ChildrenTest.php

示例13: 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:richardmiller,项目名称:phpcr-odm,代码行数:13,代码来源:MoveTest.php

示例14: testFlushSingleManagedDocument

 public function testFlushSingleManagedDocument()
 {
     $user = new CmsUser();
     $user->name = 'Dominik';
     $user->username = 'domnikl';
     $user->status = 'developer';
     $this->dm->persist($user);
     $this->dm->flush();
     $user->status = 'administrator';
     $this->dm->flush($user);
     $this->dm->clear();
     $user = $this->dm->find(get_class($user), $user->id);
     $this->assertEquals('administrator', $user->status);
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:14,代码来源:FlushTest.php

示例15: testCascadeManagedDocumentReferenceDuringFlush

 public function testCascadeManagedDocumentReferenceDuringFlush()
 {
     $article = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article->text = "foo";
     $article->topic = "bar";
     $this->dm->persist($article);
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = "beberlei";
     $user->name = "Benjamin";
     $article->user = $user;
     $this->assertFalse($this->dm->contains($user));
     $this->dm->flush();
     $this->dm->clear();
     $article = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsArticle', $article->id);
     $this->assertEquals($user->id, $article->user->getId());
 }
开发者ID:doctrine,项目名称:couchdb-odm,代码行数:16,代码来源:CascadePersistTest.php


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