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


PHP DocumentManager::find方法代码示例

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


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

示例1: testReferenceOneDifferentTargetDocuments

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

示例2: load

 /**
  * Load meta object by provided type and parameters.
  *
  * @MetaLoaderDoc(
  *     description="Article Loader loads articles from Content Repository",
  *     parameters={
  *         contentPath="SINGLE|required content path",
  *         slug="SINGLE|required content slug",
  *         pageName="COLLECTiON|name of Page for required articles"
  *     }
  * )
  *
  * @param string $type         object type
  * @param array  $parameters   parameters needed to load required object type
  * @param int    $responseType response type: single meta (LoaderInterface::SINGLE) or collection of metas (LoaderInterface::COLLECTION)
  *
  * @return Meta|Meta[]|bool false if meta cannot be loaded, a Meta instance otherwise
  */
 public function load($type, $parameters, $responseType = LoaderInterface::SINGLE)
 {
     $article = null;
     if (empty($parameters)) {
         $parameters = [];
     }
     if ($responseType === LoaderInterface::SINGLE) {
         if (array_key_exists('contentPath', $parameters)) {
             $article = $this->dm->find('SWP\\ContentBundle\\Document\\Article', $parameters['contentPath']);
         } elseif (array_key_exists('slug', $parameters)) {
             $article = $this->dm->getRepository('SWP\\ContentBundle\\Document\\Article')->findOneBy(array('slug' => $parameters['slug']));
         }
         if (!is_null($article)) {
             return new Meta($this->rootDir . '/Resources/meta/article.yml', $article);
         }
     } elseif ($responseType === LoaderInterface::COLLECTION) {
         if (array_key_exists('pageName', $parameters)) {
             $page = $this->em->getRepository('SWP\\ContentBundle\\Model\\Page')->getByName($parameters['pageName'])->getOneOrNullResult();
             if ($page) {
                 $articlePages = $this->em->getRepository('SWP\\ContentBundle\\Model\\PageContent')->getForPage($page)->getResult();
                 $articles = [];
                 foreach ($articlePages as $articlePage) {
                     $article = $this->dm->find('SWP\\ContentBundle\\Document\\Article', $articlePage->getContentPath());
                     if (!is_null($article)) {
                         $articles[] = new Meta($this->rootDir . '/Resources/meta/article.yml', $article);
                     }
                 }
                 return $articles;
             }
         }
     }
     return false;
 }
开发者ID:copyfun,项目名称:web-renderer,代码行数:51,代码来源:ArticleLoader.php

示例3: testMenuNode

 public function testMenuNode()
 {
     $data = array('name' => 'test-node', 'label' => 'label_foobar', 'uri' => 'http://www.example.com/foo', 'route' => 'foo_route', 'linkType' => 'route', 'content' => $this->content, 'publishable' => false, 'publishStartDate' => new \DateTime('2013-06-18'), 'publishEndDate' => new \DateTime('2013-06-18'), 'attributes' => array('attr_foobar_1' => 'barfoo', 'attr_foobar_2' => 'barfoo'), 'childrenAttributes' => array('child_foobar_1' => 'barfoo', 'child_foobar_2' => 'barfoo'), 'linkAttributes' => array('link_foobar_1' => 'barfoo', 'link_foobar_2' => 'barfoo'), 'labelAttributes' => array('label_foobar_1' => 'barfoo', 'label_foobar_2' => 'barfoo'), 'extras' => array('extra_foobar_1' => 'barfoo', 'extra_foobar_2' => 'barfoo'), 'routeParameters' => array('route_param_foobar_1' => 'barfoo', 'route_param_foobar_2' => 'barfoo'), 'routeAbsolute' => true, 'display' => false, 'displayChildren' => false);
     $startDateString = $data['publishStartDate']->format('Y-m-d');
     $endDateString = $data['publishEndDate']->format('Y-m-d');
     $menuNode = new MenuNode();
     $refl = new \ReflectionClass($menuNode);
     $menuNode->setParentDocument($this->rootDocument);
     foreach ($data as $key => $value) {
         $refl = new \ReflectionClass($menuNode);
         $prop = $refl->getProperty($key);
         $prop->setAccessible(true);
         $prop->setValue($menuNode, $value);
     }
     $menuNode->addChild($this->child1);
     $this->dm->persist($menuNode);
     $this->dm->flush();
     $this->dm->clear();
     $menuNode = $this->dm->find(null, '/test/test-node');
     $this->assertNotNull($menuNode);
     foreach ($data as $key => $value) {
         $prop = $refl->getProperty($key);
         $prop->setAccessible(true);
         $v = $prop->getValue($menuNode);
         if (!is_object($value)) {
             $this->assertEquals($value, $v);
         }
     }
     // test objects
     $prop = $refl->getProperty('content');
     $prop->setAccessible(true);
     $content = $prop->getValue($menuNode);
     $this->assertEquals('fake_weak_content', $content->getName());
     // test children
     $this->assertCount(1, $menuNode->getChildren());
     // test publish start and end
     $publishStartDate = $menuNode->getPublishStartDate();
     $publishEndDate = $menuNode->getPublishEndDate();
     $this->assertInstanceOf('\\DateTime', $publishStartDate);
     $this->assertInstanceOf('\\DateTime', $publishEndDate);
     $this->assertEquals($startDateString, $publishStartDate->format('Y-m-d'));
     $this->assertEquals($endDateString, $publishEndDate->format('Y-m-d'));
     // test multi-lang
     $menuNode->setLocale('fr');
     $this->dm->persist($menuNode);
     $this->dm->flush();
     $this->dm->clear();
     $menuNode = $this->dm->findTranslation(null, '/test/test-node', 'fr');
     $this->assertEquals('fr', $menuNode->getLocale());
     $child = $this->dm->find(null, '/test/test-node/child1');
     $menuNode = $child->getParent();
     $this->assertCount(1, $menuNode->getChildren());
     $menuNode->removeChild($child);
     $this->dm->flush();
     $this->dm->clear();
     $menuNode = $this->dm->find(null, '/test/test-node');
     $this->assertCount(0, $menuNode->getChildren());
 }
开发者ID:frogriotcom,项目名称:MenuBundle,代码行数:58,代码来源:MenuNodeTest.php

示例4: setUp

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

示例5: setUp

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

示例6: testMigrator

 public function testMigrator()
 {
     $this->migrator->migrate('/test/page');
     $this->migrator->migrate('/test/page/foo');
     $res = $this->dm->find(null, '/test/page');
     $this->assertNotNull($res);
     $this->assertEquals('Test', $res->getTitle());
     $res = $this->dm->find(null, '/test/page/foo');
     $this->assertNotNull($res);
     $this->assertEquals('Foobar', $res->getTitle());
 }
开发者ID:creatiombe,项目名称:SimpleCmsBundle,代码行数:11,代码来源:PageTest.php

示例7: reverseTransform

 /**
  * {@inheritdoc}
  */
 public function reverseTransform($id)
 {
     if ($id === null) {
         return;
     }
     $document = $this->manager->find(null, $id);
     if ($document === null) {
         throw new TransformationFailedException(sprintf("An document with id: %s does not exist", $id));
     }
     return $document;
 }
开发者ID:supercru,项目名称:extendedcmsbundle,代码行数:14,代码来源:ElFinderIdTransformer.php

示例8: setUp

 public function setUp()
 {
     $this->fetchDbParameters();
     $this->connection = DriverManager::getConnection($this->params);
     $this->createEntityManager();
     $this->createDocumentManager();
     $this->resetFunctionalNode($this->dm);
     $this->createObjectAdapterManager();
     NodeHelper::createPath($this->dm->getPhpcrSession(), '/functional');
     $this->base = $this->dm->find(null, '/functional');
     $this->createBaseTables();
 }
开发者ID:joschi127,项目名称:DoctrineOrmOdmAdapter,代码行数:12,代码来源:BaseFunctionalTestCase.php

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

示例10: setUp

 public function setUp()
 {
     $this->db('PHPCR')->createTestNode();
     $this->dm = $this->db('PHPCR')->getOm();
     $this->base = $this->dm->find(null, '/test');
     $this->db('PHPCR')->loadFixtures(array('Symfony\\Cmf\\Bundle\\SeoBundle\\Tests\\Resources\\DataFixtures\\Phpcr\\LoadSitemapData'));
     $this->logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->presentation = $this->getMockBuilder('\\Symfony\\Cmf\\Bundle\\SeoBundle\\SeoPresentation')->disableOriginalConstructor()->getMock();
     $this->provider = new SitemapUrlInformationProvider($this->dm, $this->getContainer()->get('router'), 'always', $this->logger, $this->presentation, $this->getContainer()->get('cmf_core.publish_workflow.checker'));
     $this->alternateLocaleProvider = $this->getMock('\\Symfony\\Cmf\\Bundle\\SeoBundle\\AlternateLocaleProviderInterface');
     $this->provider->setAlternateLocaleProvider($this->alternateLocaleProvider);
     $alternateLocale = new AlternateLocale('test', 'de');
     $this->alternateLocaleProvider->expects($this->any())->method('createForContent')->will($this->returnValue(new ArrayCollection(array($alternateLocale))));
 }
开发者ID:BiffBangPow,项目名称:SeoBundle,代码行数:14,代码来源:SitemapUrlInformationProviderTest.php

示例11: 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

示例12: testCacheNotInstanceOf

 /**
  * TypeTeamUser is not a superclass of User. Still works when loading from cache.
  */
 public function testCacheNotInstanceOf()
 {
     $user = $this->dm->find($this->type, '/functional/user');
     $this->assertInstanceOf($this->type, $user);
     $user = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\TypeTeamUser', '/functional/user');
     $this->assertTrue(null === $user, get_class($user));
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:10,代码来源:FindTypeValidationTest.php

示例13: testFetchingMultipleHierarchicalObjectsWithChildIdFirst

 public function testFetchingMultipleHierarchicalObjectsWithChildIdFirst()
 {
     $parent = new ParentTestObj();
     $parent->nodename = 'parent';
     $parent->name = 'parent';
     $parent->parent = $this->dm->find(null, 'functional');
     $child = new ParentTestObj();
     $child->nodename = 'child';
     $child->name = 'child';
     $child->parent = $parent;
     $this->dm->persist($parent);
     $this->dm->persist($child);
     $parentId = $this->uow->getDocumentId($parent);
     $childId = $this->uow->getDocumentId($child);
     $this->dm->flush();
     $this->dm->clear();
     // this forces the objects to be loaded in an order where the $parent will become a proxy
     $documents = $this->dm->findMany('Doctrine\\Tests\\Models\\References\\ParentTestObj', array($childId, $parentId));
     $this->assertCount(2, $documents);
     /* @var $child ParentTestObj */
     /* @var $parent ParentTestObj */
     $child = $documents->first();
     $parent = $documents->last();
     $this->assertSame($child->parent, $parent);
     $this->assertSame('parent', $parent->nodename);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:26,代码来源:UnitOfWorkTest.php

示例14: testProxyImplicit

 public function testProxyImplicit()
 {
     $user = new CmsUser();
     $user->name = 'Dominik';
     $user->username = 'domnikl';
     $user->status = 'developer';
     $assistant = new CmsUser();
     $assistant->username = 'bimbo';
     $user->child = $assistant;
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->find(null, $user->id);
     $assistant = $this->dm->find(null, $user->id . '/assistant');
     $this->assertSame($assistant, $user->child);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:16,代码来源:ProxyTest.php

示例15: testCascadeRemoveByCollection

 public function testCascadeRemoveByCollection()
 {
     $referrerRefManyTestObj = new ReferrerRefTestObj2();
     $referrerRefManyTestObj->id = "/functional/referrerRefManyTestObj";
     $max = 5;
     for ($i = 0; $i < $max; $i++) {
         $newReferrerTestObj = new ReferrerTestObj2();
         $newReferrerTestObj->id = "/functional/referrerTestObj{$i}";
         $newReferrerTestObj->name = "referrerTestObj{$i}";
         $newReferrerTestObj->reference = $referrerRefManyTestObj;
         $this->dm->persist($newReferrerTestObj);
     }
     $this->dm->persist($referrerRefManyTestObj);
     $this->dm->flush();
     $this->dm->clear();
     $referenced = $this->dm->find(null, "/functional/referrerRefManyTestObj");
     $this->assertCount($max, $referenced->referrers);
     $referenced->referrers->remove(0);
     $referenced->referrers->remove(3);
     $this->assertCount($max - 2, $referenced->referrers);
     $this->dm->flush();
     $this->dm->clear();
     $referenced = $this->dm->find(null, "/functional/referrerRefManyTestObj");
     $this->assertCount($max - 2, $referenced->referrers);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:25,代码来源:ReferrerTest.php


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