本文整理汇总了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();
}
示例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;
}