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


PHP SessionInterface::getNode方法代码示例

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


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

示例1: testSaveTranslation

 public function testSaveTranslation()
 {
     // First save some translations
     $data = array();
     $data['topic'] = 'Some interesting subject';
     $data['text'] = 'Lorem ipsum...';
     $node = $this->getTestNode();
     $strategy = new ChildTranslationStrategy($this->dm);
     $strategy->saveTranslation($data, $node, $this->metadata, 'en');
     // Save translation in another language
     $data['topic'] = 'Un sujet intéressant';
     $strategy->saveTranslation($data, $node, $this->metadata, 'fr');
     $this->dm->getPhpcrSession()->save();
     // Then test we have what we expect in the content repository
     $node_en = $this->session->getNode($this->nodeNameForLocale('en'));
     $node_fr = $this->session->getNode($this->nodeNameForLocale('fr'));
     $this->assertTrue($node_en->hasProperty('topic'));
     $this->assertTrue($node_fr->hasProperty('topic'));
     $this->assertTrue($node_en->hasProperty('text'));
     $this->assertTrue($node_fr->hasProperty('text'));
     $this->assertFalse($node_fr->hasProperty('author'));
     $this->assertFalse($node_en->hasProperty('author'));
     $this->assertEquals('Some interesting subject', $node_en->getPropertyValue('topic'));
     $this->assertEquals('Un sujet intéressant', $node_fr->getPropertyValue('topic'));
     $this->assertEquals('Lorem ipsum...', $node_en->getPropertyValue('text'));
     $this->assertEquals('Lorem ipsum...', $node_fr->getPropertyValue('text'));
 }
开发者ID:pkdevbox,项目名称:phpcr-odm,代码行数:27,代码来源:ChildTranslationStrategyTest.php

示例2: execute

 /**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $webspaceKey = $input->getArgument('webspaceKey');
     $locale = $input->getArgument('locale');
     $basePath = $input->getOption('base-path');
     $dryRun = $input->getOption('dry-run');
     $this->session = $this->getContainer()->get('doctrine_phpcr')->getManager()->getPhpcrSession();
     $this->sessionManager = $this->getContainer()->get('sulu.phpcr.session');
     $this->output = $output;
     $path = $this->sessionManager->getRoutePath($webspaceKey, $locale);
     $relativePath = $basePath !== null ? '/' . ltrim($basePath, '/') : '/';
     $fullPath = rtrim($path . $relativePath, '/');
     if (!$this->session->nodeExists($fullPath)) {
         $this->output->write('<error>Resource-Locator "' . $relativePath . '" not found</error>');
         return;
     }
     $node = $this->session->getNode($fullPath);
     $this->cleanup($node, $path, $dryRun);
     if (false === $dryRun) {
         $this->output->writeln('<info>Saving ...</info>');
         $this->session->save();
         $this->output->writeln('<info>Done</info>');
     } else {
         $this->output->writeln('<info>Dry run complete</info>');
     }
 }
开发者ID:ollietb,项目名称:sulu,代码行数:29,代码来源:CleanupHistoryCommand.php

示例3: getNode

 /**
  * {@inheritDoc}
  */
 protected function getNode(array $pathSegments)
 {
     $absPath = '/' . implode('/', $pathSegments);
     try {
         return $this->session->getNode($absPath);
     } catch (\PHPCR\PathNotFoundException $e) {
         return null;
     }
 }
开发者ID:frogriotcom,项目名称:glob,代码行数:12,代码来源:PhpcrTraversalFinder.php

示例4: find

 /**
  * Find a document with the given path or UUID.
  *
  * @param string $identifier UUID or path
  *
  * @return NodeInterface
  *
  * @throws DocumentNotFoundException
  */
 public function find($identifier)
 {
     try {
         if (UUIDHelper::isUUID($identifier)) {
             return $this->session->getNodeByIdentifier($identifier);
         }
         return $this->session->getNode($identifier);
     } catch (RepositoryException $e) {
         throw new DocumentNotFoundException(sprintf('Could not find document with ID or path "%s"', $identifier), null, $e);
     }
 }
开发者ID:hason,项目名称:sulu-document-manager,代码行数:20,代码来源:NodeManager.php

示例5: initPages

 private function initPages()
 {
     $this->team = $this->savePage('simple', ['title' => 'Team', 'url' => '/team'], $this->session->getNode('/cmf/sulu_io/contents')->getIdentifier());
     $this->johannes = $this->savePage('simple', ['title' => 'Johannes', 'url' => '/team/johannes'], $this->team->getUuid(), [$this->tag1->getId()]);
     $this->daniel = $this->savePage('simple', ['title' => 'Daniel', 'url' => '/team/daniel'], $this->team->getUuid());
     $this->thomas = $this->savePage('simple', ['title' => 'Thomas', 'url' => '/team/thomas'], $this->team->getUuid());
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:7,代码来源:SmartContentItemControllerTest.php

示例6: upgradeLocale

 private function upgradeLocale(Webspace $webspace, Localization $localization, OutputInterface $output)
 {
     $output->writeln('  > Upgrade Locale: ' . $localization->getLocalization('-'));
     $contentNode = $this->liveSession->getNode($this->sessionManager->getContentPath($webspace->getKey()));
     $this->upgradeNode($contentNode, $webspace, $localization, $output);
     $this->upgradeByParent($contentNode, $webspace, $localization, $output);
 }
开发者ID:sulu,项目名称:sulu,代码行数:7,代码来源:MaintainResourceLocatorCommand.php

示例7: testSubRegionSaveTranslation

 public function testSubRegionSaveTranslation()
 {
     // First save some translations
     $data = array();
     $data['topic'] = 'Some interesting subject';
     $data['text'] = 'Lorem ipsum...';
     $node = $this->getTestNode();
     $strategy = new AttributeTranslationStrategy($this->dm);
     $strategy->saveTranslation($data, $node, $this->metadata, 'en');
     // Save translation in another language
     $data['topic'] = 'Some interesting american subject';
     $strategy->saveTranslation($data, $node, $this->metadata, 'en_US');
     $this->dm->flush();
     // Then test we have what we expect in the content repository
     $node = $this->session->getNode('/' . $this->testNodeName);
     $this->assertTrue($node->hasProperty(self::propertyNameForLocale('en', 'topic')));
     $this->assertTrue($node->hasProperty(self::propertyNameForLocale('en_US', 'topic')));
     $this->assertTrue($node->hasProperty(self::propertyNameForLocale('en', 'text')));
     $this->assertTrue($node->hasProperty(self::propertyNameForLocale('en_US', 'text')));
     $this->assertFalse($node->hasProperty(self::propertyNameForLocale('en', 'author')));
     $this->assertFalse($node->hasProperty(self::propertyNameForLocale('en_US', 'author')));
     $this->assertEquals('Some interesting subject', $node->getPropertyValue(self::propertyNameForLocale('en', 'topic')));
     $this->assertEquals('Some interesting american subject', $node->getPropertyValue(self::propertyNameForLocale('en_US', 'topic')));
     $this->assertEquals('Lorem ipsum...', $node->getPropertyValue(self::propertyNameForLocale('en', 'text')));
     $this->assertEquals('Lorem ipsum...', $node->getPropertyValue(self::propertyNameForLocale('en_US', 'text')));
     // make sure getLocalesFor works as well.
     $doc = new Article();
     $locales = $strategy->getLocalesFor($doc, $node, $this->metadata);
     $this->assertEquals(array('en', 'en_US'), $locales);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:30,代码来源:AttributeTranslationStrategyTest.php

示例8: updateRoute

 /**
  * Updates the route for the given document after a move or copy.
  *
  * @param object $document
  * @param bool $generateRoutes If set to true a route in the routing tree will also be created
  */
 private function updateRoute($document, $generateRoutes)
 {
     $locales = $this->documentInspector->getLocales($document);
     $webspaceKey = $this->documentInspector->getWebspace($document);
     $uuid = $this->documentInspector->getUuid($document);
     $path = $this->documentInspector->getPath($document);
     $parentUuid = $this->documentInspector->getUuid($this->documentInspector->getParent($document));
     $defaultNode = $this->defaultSession->getNode($path);
     $liveNode = $this->liveSession->getNode($path);
     $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
     foreach ($locales as $locale) {
         $localizedDocument = $this->documentManager->find($uuid, $locale);
         if ($localizedDocument->getRedirectType() !== RedirectType::NONE) {
             continue;
         }
         $resourceSegmentPropertyName = $this->encoder->localizedSystemName($this->getResourceSegmentProperty($localizedDocument)->getName(), $locale);
         $this->updateResourceSegmentProperty($defaultNode, $resourceSegmentPropertyName, $parentUuid, $webspaceKey, $locale);
         if ($liveNode->hasProperty($resourceSegmentPropertyName)) {
             $this->updateResourceSegmentProperty($liveNode, $resourceSegmentPropertyName, $parentUuid, $webspaceKey, $locale);
             // if the method is called with the generateRoutes flag it will create a new route
             // this happens on a move, but not on copy, because copy results in a draft page without url
             if ($generateRoutes) {
                 $localizedDocument->setResourceSegment($liveNode->getPropertyValue($resourceSegmentPropertyName));
                 $resourceLocatorStrategy->save($localizedDocument, null);
                 $localizedDocument->setResourceSegment($defaultNode->getPropertyValue($resourceSegmentPropertyName));
             }
         }
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:35,代码来源:ResourceSegmentSubscriber.php

示例9: getNodeForDocument

 /**
  * {@inheritDoc}
  */
 public function getNodeForDocument($document)
 {
     if (!is_object($document)) {
         throw new InvalidArgumentException('Parameter $document needs to be an object, ' . gettype($document) . ' given');
     }
     $path = $this->unitOfWork->getDocumentId($document);
     return $this->session->getNode($path);
 }
开发者ID:pkdevbox,项目名称:phpcr-odm,代码行数:11,代码来源:DocumentManager.php

示例10: visitAncestors

 /**
  * Let the visitor visit the ancestors from root node according to mapper
  * down to the parent of the node identified by url
  *
  * @param string $url the url (without eventual prefix from routing config)
  * @param ItemVisitorInterface $visitor the visitor to look at the nodes
  */
 public function visitAncestors($url, ItemVisitorInterface $visitor)
 {
     $node = $this->session->getNode($this->mapper->getStorageId($url));
     $i = $this->rootnode->getDepth();
     while (($ancestor = $node->getAncestor($i++)) != $node) {
         $ancestor->accept($visitor);
     }
 }
开发者ID:ronnylt,项目名称:symfony-cmf,代码行数:15,代码来源:HierarchyWalker.php

示例11: testRemove

 public function testRemove()
 {
     $this->property->expects($this->any())->method('getName')->will($this->returnValue('i18n:de-hotels'));
     $pageNode = $this->session->getNode('/cmf/sulu_io/contents/hotels');
     $this->contentType->remove($pageNode, $this->property, 'sulu_io', 'de', null);
     $this->session->save();
     $this->assertFalse($pageNode->hasProperty('i18n:de-hotels'));
 }
开发者ID:jimblizz,项目名称:sulu,代码行数:8,代码来源:SnippetContentTest.php

示例12: refresh

 /**
  * Refresh the given document by querying the PHPCR to get the current state.
  *
  * @param object $document
  * @return object Document instance
  */
 public function refresh($document)
 {
     $this->errorIfClosed();
     $this->session->refresh(true);
     $node = $this->session->getNode($this->unitOfWork->getDocumentId($document));
     $hints = array('refresh' => true);
     return $this->unitOfWork->createDocument(get_class($document), $node, $hints);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:14,代码来源:DocumentManager.php

示例13: handleSession

 private function handleSession(SessionInterface $session, $fileName)
 {
     if ($session->getRootNode()->hasNode('cmf')) {
         $session->getNode('/cmf')->remove();
         $session->save();
     }
     $session->importXML('/', $fileName, ImportUUIDBehaviorInterface::IMPORT_UUID_COLLISION_THROW);
     $session->save();
 }
开发者ID:sulu,项目名称:sulu,代码行数:9,代码来源:PHPCRImporter.php

示例14: removeTestNode

 /**
  * Remove a PHPCR node under the root node
  *
  * @param string $name The name of the node to remove
  *
  * @return void
  */
 protected function removeTestNode($name)
 {
     $root = $this->session->getNode('/');
     if ($root->hasNode($name)) {
         $root->getNode($name)->remove();
         $this->session->save();
         $this->dm->clear();
     }
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:16,代码来源:AnnotationsTest.php

示例15: match

 /**
  * {@inheritDoc}
  */
 public function match(EventInterface $event)
 {
     if (!$event->getPath()) {
         // Some events (like PERSIST) don't have a path
         return false;
     }
     // An event might have been raised for a node that does not exist anymore
     if (!$this->session->nodeExists($event->getPath())) {
         return false;
     }
     $node = $this->session->getNode($event->getPath());
     foreach ($this->nodeTypes as $type) {
         if ($node->isNodeType($type)) {
             return true;
         }
     }
     return false;
 }
开发者ID:ruflin,项目名称:jackalope,代码行数:21,代码来源:NodeTypeEventFilter.php


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