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


PHP NodeInterface::getNode方法代码示例

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


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

示例1: 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:nikophil,项目名称:cmf-tests,代码行数:13,代码来源:FixPHPCR1Test.php

示例2: testFindTranslationWithUntranslatedChildren

 /**
  * Test that children are retrieved in the parent locale
  */
 public function testFindTranslationWithUntranslatedChildren()
 {
     $this->dm->persist($this->doc);
     $this->dm->bindTranslation($this->doc, 'en');
     $this->doc->topic = 'Un autre sujet';
     $this->dm->bindTranslation($this->doc, 'fr');
     $this->dm->flush();
     $testNode = $this->node->getNode($this->testNodeName);
     $testNode->addNode('new-comment');
     $this->session->save();
     $this->dm->clear();
     $this->doc = $this->dm->findTranslation($this->class, '/functional/' . $this->testNodeName, 'fr');
     $this->assertEquals('fr', $this->doc->locale);
     $children = $this->doc->getChildren();
     $this->assertCount(1, $children);
     foreach ($children as $comment) {
         $this->assertInstanceOf('Doctrine\\ODM\\PHPCR\\Document\\Generic', $comment);
         $this->assertNull($this->dm->getUnitOfWork()->getCurrentLocale($comment));
     }
     $this->dm->clear();
     $this->doc = $this->dm->findTranslation($this->class, '/functional/' . $this->testNodeName, 'en');
     $children = $this->dm->getChildren($this->doc);
     $this->assertCount(1, $children);
     foreach ($children as $comment) {
         $this->assertInstanceOf('Doctrine\\ODM\\PHPCR\\Document\\Generic', $comment);
         $this->assertNull($this->dm->getUnitOfWork()->getCurrentLocale($comment));
     }
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:31,代码来源:DocumentManagerTest.php

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

示例4: getUrl

    /**
     * Gets a relative filesystem path based on the repository path, AND
     * creates the file on the filesystem if it's in the repository
     * and not yet on the filesystem.
     * The repository path points to a nt-resource node, whose title
     * should be the filename, and which has a child+property
     * jcr:content/jcr:data where the file data is stored.
     *
     * @param string $path path to the nt-resource node.
     * @return string with a path to the file, relative to the web directory.
     */
    public function getUrl(NodeInterface $node)
    {

        $hasData = false;
        if ($node->hasNode('jcr:content')) {
            $contentNode = $node->getNode('jcr:content');
            if ($contentNode->hasProperty('jcr:data')) {
                $hasData = true;
            }
        }
        if (!$hasData) {
            //TODO: notfound exception is not appropriate ... how to best do this?
            //throw new NotFoundHttpException('no picture found at ' . $node->getPath());
            return 'notfound';
        }

        $path = $node->getPath();
        $relativePath = $this->pathMapper->getUrl($path);
        $fullPath = $this->fileBasePath . $relativePath . $this->getExtension($contentNode);

        if (!file_exists($fullPath)) {
            try {
                $this->saveData($contentNode, $fullPath);
            } catch (Imagine\Exception\Exception $e) {
                //TODO: notfound exception is not appropriate ... how to best do this?
                //throw new NotFoundHttpException('image save to filesystem failed: ' . $e->getMessage());
                return 'notfound';
            }
        }

        return $this->webRelativePath . $relativePath . $this->getExtension($contentNode);
    }
开发者ID:ralf57,项目名称:CoreBundle,代码行数:43,代码来源:RepositoryFileHelper.php

示例5: getUrl

 /**
  * Gets a relative filesystem path based on the repository path, AND
  * creates the file on the filesystem if it's in the repository
  * and not yet on the filesystem.
  * The repository path points to a nt-resource node, whose title
  * should be the filename, and which has a child+property
  * jcr:content/jcr:data where the file data is stored.
  *
  * @param string $path path to the nt-resource node.
  * @return string with a path to the file, relative to the web directory.
  */
 public function getUrl(NodeInterface $node)
 {
     $hasData = false;
     if ($node->hasNode('jcr:content')) {
         $contentNode = $node->getNode('jcr:content');
         if ($contentNode->hasProperty('jcr:data')) {
             $hasData = true;
         }
     }
     if (!$hasData) {
         //TODO: notfound exception is not appropriate ... how to best do this?
         //throw new NotFoundHttpException('no picture found at ' . $node->getPath());
         return 'notfound';
     }
     $path = $node->getPath();
     $relativePath = $this->pathMapper->getUrl($path);
     $extension = $this->getExtension($contentNode);
     $fullPath = $this->fileBasePath . '/' . $relativePath . $extension;
     if (!file_exists($fullPath)) {
         if (!$this->saveData($contentNode, $fullPath)) {
             throw new FileException('failed to save data to file: ' . $fullPath);
         }
     }
     return $this->webRelativePath . '/' . $relativePath . $extension;
 }
开发者ID:richardmiller,项目名称:symfony-cmf,代码行数:36,代码来源:RepositoryFileHelper.php

示例6: 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:nikophil,项目名称:cmf-tests,代码行数:17,代码来源:PropertyNameTest.php

示例7: testCreateFromString

 public function testCreateFromString()
 {
     $parent = new FileTestObj();
     $parent->file = new File();
     $parent->id = '/functional/filetest';
     $parent->file->setFileContent('Lorem ipsum dolor sit amet');
     $this->dm->persist($parent);
     $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'));
     $binaryStream = $this->node->getNode('filetest')->getNode('file')->getNode('jcr:content')->getProperty('jcr:data')->getBinary();
     $this->assertNotNull($binaryStream, 'Ensure that we got a stream from the file');
     $content = stream_get_contents($binaryStream);
     $this->assertEquals('Lorem ipsum dolor sit amet', $content);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:17,代码来源:FileTest.php

示例8: testBindTranslation

 public function testBindTranslation()
 {
     $parent = $this->dm->find($this->type, '/functional/thename');
     $child = new Article();
     $child->parent = $parent;
     $child->id = '/functional/thename/child';
     $child->author = 'John Doe';
     $child->topic = 'Some interesting subject';
     $child->text = 'Lorem ipsum...';
     $this->dm->persist($child);
     $this->dm->bindTranslation($child, 'fr');
     $this->dm->flush();
     $this->assertTrue($this->node->getNode('thename')->hasNode('child'));
     $this->assertEquals('/functional/thename/child', $child->id);
     $this->dm->clear();
     $child = $this->dm->findTranslation($this->type, '/functional/thename/child', 'fr');
     $this->assertEquals('fr', $child->locale);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:18,代码来源:TranslationHierarchyTest.php

示例9: getTranslationNode

 protected function getTranslationNode(NodeInterface $parentNode, $locale)
 {
     $name = Translation::LOCALE_NAMESPACE . ":{$locale}";
     if (!$parentNode->hasNode($name)) {
         $node = $parentNode->addNode($name);
     } else {
         $node = $parentNode->getNode($name);
     }
     return $node;
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:10,代码来源:ChildTranslationStrategy.php

示例10: testChangeset

 public function testChangeset()
 {
     $user = $this->node->getNode('user');
     // the property is not nullable, but this should only be checked on saving, not on loading
     $user->getProperty('username')->remove();
     $this->dm->getPhpcrSession()->save();
     $userDoc = $this->dm->find(null, $user->getPath());
     $this->assertInstanceOf($this->type, $userDoc);
     $this->assertNull($userDoc->username);
     // nothing should happen, we did not alter any value
     $this->dm->flush();
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:12,代码来源:BasicCrudTest.php

示例11: testChangingProtectedPropertyToNullThrowsException

 /**
  * @expectedException \PHPCR\NodeType\ConstraintViolationException
  */
 public function testChangingProtectedPropertyToNullThrowsException()
 {
     $test = new TestObject();
     $test->id = '/functional/protected';
     $test->changeMe = 'test';
     $this->dm->persist($test);
     $this->dm->flush();
     $this->dm->clear();
     $test = $this->dm->find(null, '/functional/protected');
     $test->changeMe = 'changed';
     $test->created = null;
     $this->dm->flush();
     $this->assertEquals('changed', $this->node->getNode('protected')->getProperty('change_me')->getString());
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:17,代码来源:MixinTest.php

示例12: resolveName

 /**
  * @param NodeInterface $parentNode
  * @param string $name
  * @param null|NodeInterface $forNode
  *
  * @return string
  */
 public function resolveName(NodeInterface $parentNode, $name, $forNode = null)
 {
     if ($forNode && $parentNode->hasNode($name) && $parentNode->getNode($name) == $forNode) {
         return $name;
     }
     $index = 0;
     $baseName = $name;
     do {
         if ($index > 0) {
             $name = $baseName . '-' . $index;
         }
         $hasChild = $parentNode->hasNode($name);
         ++$index;
     } while ($hasChild);
     return $name;
 }
开发者ID:hason,项目名称:sulu-document-manager,代码行数:23,代码来源:NameResolver.php

示例13: assertFolderAndFile

 /**
  * Assert that $node has a folder child that is an nt:folder and has a
  * child * called file that is an nt:file.
  *
  * @param NodeInterface $node
  */
 private function assertFolderAndFile(NodeInterface $node)
 {
     $this->assertTrue($node->hasNode('folder'));
     $folder = $node->getNode('folder');
     $this->assertTrue($folder->hasProperty('jcr:created'));
     $this->assertInstanceOf('\\DateTime', $folder->getPropertyValue('jcr:created'));
     $this->assertTrue($folder->hasNode('file'));
     $file = $folder->getNode('file');
     $this->assertTrue($file->hasNode('jcr:content'));
     $resource = $file->getNode('jcr:content');
     $this->assertTrue($resource->hasProperty('jcr:lastModified'));
     $this->assertInstanceOf('\\DateTime', $resource->getPropertyValue('jcr:lastModified'));
     $this->assertTrue($resource->hasProperty('jcr:data'));
     $binaryStream = $file->getNode('jcr:content')->getProperty('jcr:data')->getBinary();
     $this->assertNotNull($binaryStream, 'We got no content from the file');
     $content = stream_get_contents($binaryStream);
     $this->assertEquals(self::FILE_CONTENT, $content);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:24,代码来源:FolderFileTest.php

示例14: testMoveByAssignmentWithProxy

 public function testMoveByAssignmentWithProxy()
 {
     $user = $this->node->getNode('dbu')->addNode('assistant');
     $user->setProperty('username', 'foo');
     $user->setProperty('status', 'created');
     $user->setProperty('phpcr:class', $this->type, PropertyType::STRING);
     $this->dm->getPhpcrSession()->save();
     $this->dm->clear();
     $user = $this->dm->find($this->type, '/functional/dbu');
     $this->assertNotNull($user, 'User must exist');
     $team = $this->dm->find($this->type, '/functional/team');
     $this->assertNotNull($team, 'Team must exist');
     $user->parent = $team;
     $this->assertFalse($user->child->__isInitialized());
     $this->dm->flush();
     $this->assertFalse($user->child->__isInitialized());
     $this->assertEquals('/functional/team/dbu/assistant', $user->child->getId());
     $this->assertEquals('foo', $user->child->getUsername());
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:19,代码来源:MoveByAssignmentTest.php

示例15: testInsertGrandchildWithNewParent

 public function testInsertGrandchildWithNewParent()
 {
     $parent = new NameDoc();
     $parent->id = '/functional/parent';
     $child = new NameDoc();
     $child->parent = $parent;
     $child->nodename = 'child';
     $parent->children = array($child);
     # the grand child document
     $grandchild = new NameDoc();
     $grandchild->parent = $child;
     $grandchild->nodename = 'grandchild';
     $child->children = array($grandchild);
     $this->dm->persist($child);
     $this->dm->flush();
     $this->assertTrue($this->node->getNode('parent')->hasNode('child'));
     $this->assertEquals('/functional/parent/child', $child->id);
     $this->assertTrue($this->node->getNode('parent')->getNode('child')->hasNode('grandchild'));
     $this->assertEquals('/functional/parent/child/grandchild', $grandchild->id);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:20,代码来源:ParentTest.php


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