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


PHP DocumentManager::persist方法代码示例

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


在下文中一共展示了DocumentManager::persist方法的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: testLuceneIndexing

 public function testLuceneIndexing()
 {
     $this->dm->getConfiguration()->addDesignDocument('lucene_users', 'Doctrine\\Tests\\ODM\\CouchDB\\Functional\\LuceneQueryDesignDoc', array());
     $query = $this->dm->createLuceneQuery('lucene_users', 'by_name');
     $response = $query->createDesignDocument();
     $user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user1->username = "beberlei";
     $user1->status = "active";
     $user1->name = "Benjamin";
     $user2 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user2->username = "lsmith";
     $user2->status = "active";
     $user2->name = "Lukas";
     $this->dm->persist($user1);
     $this->dm->persist($user2);
     $this->dm->flush();
     $query->setQuery("Lukas");
     try {
         $result = $query->execute();
     } catch (\Doctrine\CouchDB\HTTP\HTTPException $e) {
         if ($e->getCode() == 404) {
             $this->markTestSkipped("Lucene is not integrated");
         } else {
             throw $e;
         }
     }
     $this->assertEquals(1, count($result));
     foreach ($result as $user) {
         $this->assertEquals($user2->id, $user['id']);
         $this->assertEquals(1, $user['score']);
     }
     $query->setIncludeDocs(true)->setDocumentName('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $result = $query->execute();
     $this->assertSame($user2, $result[0]['doc']);
 }
开发者ID:kevinyien,项目名称:couchdb-odm,代码行数:35,代码来源:LuceneQueryTest.php

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

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

示例5: testCreateFromFile

 public function testCreateFromFile()
 {
     $parent = new FixPHPCR1TestObj();
     $parent->id = '/functional/filetest';
     $this->dm->persist($parent);
     $parent->file = new File();
     $parent->file->setFileContentFromFilesystem(dirname(__FILE__) . '/_files/foo.txt');
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->node->getNode('filetest')->hasNode('file'));
     $this->assertTrue($this->node->getNode('filetest')->getNode('file')->hasNode('jcr:content'));
     $this->assertTrue($this->node->getNode('filetest')->getNode('file')->getNode('jcr:content')->hasProperty('jcr:data'));
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:13,代码来源:FixPHPCR1Test.php

示例6: testMoveWithChild

 public function testMoveWithChild()
 {
     $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();
     $user1 = $this->dm->find($this->type, '/functional/lsmith');
     $this->dm->move($user1, '/functional/user2');
     $this->dm->flush();
     $this->dm->clear();
     $user1 = $this->dm->find($this->type, '/functional/user2');
     $user = $this->dm->find($this->type, '/functional/user2');
     $this->assertNotNull($user, 'User must exist');
     $user = $this->dm->find($this->type, '/functional/user2/jwage');
     $this->assertNotNull($user, 'User must exist');
     $user = $this->dm->find($this->type, '/functional/user2/jwage/beberlei');
     $this->assertNotNull($user, 'User must exist');
     $this->dm->move($user1, '/functional/lsmith');
     $this->dm->flush();
     $user = $this->dm->find($this->type, '/functional/lsmith');
     $this->assertNotNull($user, 'User must exist');
     $user = $this->dm->find($this->type, '/functional/lsmith/jwage');
     $this->assertNotNull($user, 'User must exist');
     $user = $this->dm->find($this->type, '/functional/lsmith/jwage/beberlei');
     $this->assertNotNull($user, 'User must exist');
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:33,代码来源:MoveTest.php

示例7: testDetachWithPerist

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

示例8: testCascadeRemoveSingleDocument

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

示例9: testSecoundLevelOverwrite

 public function testSecoundLevelOverwrite()
 {
     $localePrefs = array('en' => array('en', 'de'), 'de' => array('de', 'en'));
     $this->dm->setLocaleChooserStrategy(new LocaleChooser($localePrefs, 'en'));
     $secondTrans = new SecondLevelWithDuplicateOverwrite();
     $secondTrans->id = '/functional/secondTrans';
     $secondTrans->text = 'deutsch';
     $this->dm->persist($secondTrans);
     $this->dm->bindTranslation($secondTrans, 'de');
     $secondTrans->text = 'english';
     $this->dm->bindTranslation($secondTrans, 'en');
     $this->dm->flush();
     $tmpDocDe = $this->dm->findTranslation(null, '/functional/secondTrans', 'de');
     $this->assertEquals($tmpDocDe->text, 'deutsch');
     $tmpDocEn = $this->dm->findTranslation(null, '/functional/secondTrans', 'en');
     $this->assertEquals($tmpDocEn->text, 'english');
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:17,代码来源:AnnotationMappingTest.php

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

示例11: testCascadeRemoveReferrer

 public function testCascadeRemoveReferrer()
 {
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = 'beberlei';
     $user->name = 'Benjamin';
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->flush();
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:9,代码来源:CascadeRemoveTest.php

示例12: testCascadeRefresh

 public function testCascadeRefresh()
 {
     $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group1->name = "Test!";
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = "beberlei";
     $user->name = "Benjamin";
     $user->addGroup($group1);
     $this->dm->persist($user);
     $this->dm->persist($group1);
     $this->dm->flush();
     $this->assertEquals(1, count($user->groups));
     $group1->name = "Test2";
     $user->username = "beberlei2";
     $this->dm->refresh($user);
     $this->assertEquals("beberlei", $user->username);
     $this->assertEquals("Test!", $group1->name);
 }
开发者ID:doctrine,项目名称:couchdb-odm,代码行数:18,代码来源:CascadeRefreshTest.php

示例13: testCreateCascade

 public function testCreateCascade()
 {
     $folder = new Folder();
     $folder->setId('/functional/folder');
     $file = new File();
     $file->setFileContent('Lorem ipsum dolor sit amet');
     $file->setNodename('file');
     $folder->addChild($file);
     $this->dm->persist($folder);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->node->hasNode('folder'));
     $this->assertTrue($this->node->getNode('folder')->hasNode('file'));
     $this->assertTrue($this->node->getNode('folder')->getNode('file')->hasNode('jcr:content'));
     $this->assertTrue($this->node->getNode('folder')->getNode('file')->getNode('jcr:content')->hasProperty('jcr:data'));
     $binaryStream = $this->node->getNode('folder')->getNode('file')->getNode('jcr:content')->getProperty('jcr:data')->getBinary();
     $content = stream_get_contents($binaryStream);
     $this->assertEquals('Lorem ipsum dolor sit amet', $content);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:19,代码来源:FolderTest.php

示例14: testPersistVersionError

 /**
  * @expectedException InvalidArgumentException
  */
 public function testPersistVersionError()
 {
     $doc = $this->dm->find($this->type, '/functional/versionTestObj');
     $this->dm->checkpoint($doc);
     $linearVersionHistory = $this->dm->getAllLinearVersions($doc);
     $lastVersion = end($linearVersionHistory);
     $lastVersionName = $lastVersion['name'];
     $frozenDocument = $this->dm->findVersionByName($this->type, '/functional/versionTestObj', $lastVersionName);
     $this->dm->persist($frozenDocument);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:13,代码来源:VersioningTest.php

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


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