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


PHP NodeDataRepository::findByWorkspace方法代码示例

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


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

示例1: removeUndefinedProperties

 /**
  * Performs checks for orphan nodes removes them if found.
  *
  * @param string $workspaceName
  * @param boolean $dryRun Simulate?
  * @param NodeType $nodeType Only for this node type, if specified
  * @return void
  */
 public function removeUndefinedProperties($workspaceName, $dryRun, NodeType $nodeType = null)
 {
     $this->output->outputLine('Checking for undefined properties ...');
     /** @var \TYPO3\TYPO3CR\Domain\Model\Workspace $workspace */
     $workspace = $this->workspaceRepository->findByIdentifier($workspaceName);
     $nodesWithUndefinedPropertiesNodes = array();
     $undefinedPropertiesCount = 0;
     $nodes = $nodeType !== null ? $this->getNodeDataByNodeTypeAndWorkspace($nodeType, $workspaceName) : $this->nodeDataRepository->findByWorkspace($workspace);
     foreach ($nodes as $nodeData) {
         try {
             /** @var NodeData $nodeData */
             if ($nodeData->getNodeType()->getName() === 'unstructured') {
                 continue;
             }
             $context = $this->nodeFactory->createContextMatchingNodeData($nodeData);
             $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
             if (!$node instanceof NodeInterface) {
                 continue;
             }
             $nodeType = $node->getNodeType();
             $undefinedProperties = array_diff(array_keys($node->getProperties()), array_keys($nodeType->getProperties()));
             if ($undefinedProperties !== array()) {
                 $nodesWithUndefinedPropertiesNodes[$node->getIdentifier()] = array('node' => $node, 'undefinedProperties' => $undefinedProperties);
                 foreach ($undefinedProperties as $undefinedProperty) {
                     $undefinedPropertiesCount++;
                     $this->output->outputLine('Found undefined property named "%s" in "%s" (%s)', array($undefinedProperty, $node->getPath(), $node->getNodeType()->getName()));
                 }
             }
         } catch (NodeTypeNotFoundException $exception) {
             $this->output->outputLine('Skipped undefined node type in "%s"', array($nodeData->getPath()));
         }
     }
     if ($undefinedPropertiesCount > 0) {
         $this->output->outputLine();
         if (!$dryRun) {
             $self = $this;
             $this->askBeforeExecutingTask('Do you want to remove undefined node properties?', function () use($self, $nodesWithUndefinedPropertiesNodes, $undefinedPropertiesCount, $workspaceName, $dryRun) {
                 foreach ($nodesWithUndefinedPropertiesNodes as $nodesWithUndefinedPropertiesNode) {
                     /** @var NodeInterface $node */
                     $node = $nodesWithUndefinedPropertiesNode['node'];
                     foreach ($nodesWithUndefinedPropertiesNode['undefinedProperties'] as $undefinedProperty) {
                         if ($node->hasProperty($undefinedProperty)) {
                             $node->removeProperty($undefinedProperty);
                         }
                     }
                 }
                 $self->output->outputLine('Removed %s undefined propert%s.', array($undefinedPropertiesCount, $undefinedPropertiesCount > 1 ? 'ies' : 'y'));
             });
         } else {
             $this->output->outputLine('Found %s undefined propert%s to be removed.', array($undefinedPropertiesCount, $undefinedPropertiesCount > 1 ? 'ies' : 'y'));
         }
         $this->output->outputLine();
     }
     $this->persistenceManager->persistAll();
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:63,代码来源:NodeCommandControllerPlugin.php

示例2: getUnpublishedNodes

 /**
  * Returns a list of nodes contained in the given workspace which are not yet published
  *
  * @param Workspace $workspace
  * @return array<\TYPO3\TYPO3CR\Domain\Model\NodeInterface>
  * @api
  */
 public function getUnpublishedNodes(Workspace $workspace)
 {
     if ($workspace->getBaseWorkspace() === NULL) {
         return array();
     }
     $nodeData = $this->nodeDataRepository->findByWorkspace($workspace);
     $unpublishedNodes = array();
     foreach ($nodeData as $singleNodeData) {
         /** @var NodeData $singleNodeData */
         // Skip the root entry from the workspace as it can't be published
         if ($singleNodeData->getPath() === '/') {
             continue;
         }
         $node = $this->nodeFactory->createFromNodeData($singleNodeData, $this->createContext($workspace, $singleNodeData->getDimensionValues()));
         if ($node !== NULL) {
             $unpublishedNodes[] = $node;
         }
     }
     $unpublishedNodes = $this->sortNodesForPublishing($unpublishedNodes);
     return $unpublishedNodes;
 }
开发者ID:radmiraal,项目名称:neos-development-collection,代码行数:28,代码来源:PublishingService.php


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