當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DocumentManager類代碼示例

本文整理匯總了PHP中DocumentManager的典型用法代碼示例。如果您正苦於以下問題:PHP DocumentManager類的具體用法?PHP DocumentManager怎麽用?PHP DocumentManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DocumentManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 public function save(AbstractEntity $entity)
 {
     if ($entity->getStorageStructure() == AbstractEntity::DOCUMENT) {
         $dm = new DocumentManager();
         $document = $entity->toDocument();
         $dm->persist($document);
     }
     if ($entity->getStorageStructure() == AbstractEntity::RELATIONAL) {
         $rm = new RecordManager();
         $record = $entity->toRecord();
         $rm->save($record);
     }
 }
開發者ID:pelif,項目名稱:curso-design-pattern,代碼行數:13,代碼來源:PersistenceManager.php

示例2: fixDocumentNameCallback

function fixDocumentNameCallback($p_event, &$p_header)
{
    global $remove_dir;
    $files = Session::read('doc_files_to_download');
    $storedFile = $remove_dir . $p_header['stored_filename'];
    if (!isset($files[$storedFile])) {
        return 0;
    }
    $documentData = $files[$storedFile];
    $documentNameFixed = DocumentManager::undoFixDocumentName($documentData['path'], $documentData['c_id'], $documentData['session_id'], $documentData['to_group_id']);
    // Changes file.phps to file.php
    $basename = basename($documentNameFixed);
    $basenamePHPFixed = str_replace('.phps', '.php', $basename);
    $documentNameFixed = str_replace($basename, $basenamePHPFixed, $documentNameFixed);
    if ($remove_dir != '/') {
        $documentNameFixed = str_replace($remove_dir, '/', $documentNameFixed);
        if (substr($documentNameFixed, 0, 1) == '/') {
            $documentNameFixed = substr($documentNameFixed, 1, api_strlen($documentNameFixed));
        }
    } else {
        $documentNameFixed = ltrim($documentNameFixed, '/');
    }
    $p_header['stored_filename'] = $documentNameFixed;
    return 1;
}
開發者ID:omaoibrahim,項目名稱:chamilo-lms,代碼行數:25,代碼來源:downloadfolder.inc.php

示例3: testProxyFactorySetsProxyMetadata

 public function testProxyFactorySetsProxyMetadata()
 {
     $proxy = $this->dm->getReference($this->type, 1);
     $proxyClass = get_class($proxy);
     $this->assertTrue($this->dm->getClassMetadataFactory()->hasMetadataFor($proxyClass), "Proxy class '" . $proxyClass . "' should be registered as metadata.");
     $this->assertSame($this->dm->getClassMetadata($proxyClass), $this->dm->getClassMetadata($this->type), "Metadata instances of proxy class and real instance have to be the same.");
 }
開發者ID:hlubek,項目名稱:couchdb-odm,代碼行數:7,代碼來源:ProxyTest.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();
     $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

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

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

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

示例8: testGetChanges

 /**
  * @depends testCreateBulkUpdater
  */
 public function testGetChanges()
 {
     $updater = $this->couchClient->createBulkUpdater();
     $updater->updateDocument(array("_id" => "test1", "foo" => "bar"));
     $updater->updateDocument(array("_id" => "test2", "bar" => "baz"));
     $updater->execute();
     $changes = $this->couchClient->getChanges();
     $this->assertArrayHasKey('results', $changes);
     $this->assertEquals(2, count($changes['results']));
     $this->assertEquals(2, $changes['last_seq']);
 }
開發者ID:hlubek,項目名稱:couchdb-odm,代碼行數:14,代碼來源:CouchDBClientTest.php

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

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

示例11: find

 /**
  * Finds a document by its identifier.
  *
  * @param $id The identifier.
  * @param int $lockMode
  * @param int $lockVersion
  * @return object The document.
  */
 public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
 {
     // Check identity map first
     if ($document = $this->uow->tryGetById($id, $this->class->rootDocumentName)) {
         if ($lockMode != LockMode::NONE) {
             $this->dm->lock($document, $lockMode, $lockVersion);
         }
         return $document;
         // Hit!
     }
     $id = array('_id' => $id);
     if ($lockMode == LockMode::NONE) {
         return $this->uow->getDocumentPersister($this->documentName)->load($id);
     } else {
         if ($lockMode == LockMode::OPTIMISTIC) {
             if (!$this->class->isVersioned) {
                 throw LockException::notVersioned($this->documentName);
             }
             $document = $this->uow->getDocumentPersister($this->documentName)->load($id);
             $this->uow->lock($document, $lockMode, $lockVersion);
             return $document;
         } else {
             return $this->uow->getDocumentPersister($this->documentName)->load($id, null, array(), $lockMode);
         }
     }
 }
開發者ID:faridos,項目名稱:ServerGroveLiveChat,代碼行數:34,代碼來源:DocumentRepository.php

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

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

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

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


注:本文中的DocumentManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。