Neos\ContentRepository\Command\NodeCommandControllerPlugin::collectNodesWithInvalidDimensions PHP Метод

collectNodesWithInvalidDimensions() защищенный Метод

Collects all nodes of the given node type which have dimension values not fitting to the current dimension configuration.
protected collectNodesWithInvalidDimensions ( string $workspaceName, array $allowedDimensionCombinations ) : array
$workspaceName string
$allowedDimensionCombinations array
Результат array
    protected function collectNodesWithInvalidDimensions($workspaceName, array $allowedDimensionCombinations)
    {
        $nodes = [];
        ksort($allowedDimensionCombinations);
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('n')->from(NodeData::class, 'n')->where('n.workspace = :workspace')->setParameter('workspace', $workspaceName);
        foreach ($queryBuilder->getQuery()->getArrayResult() as $nodeDataArray) {
            if ($nodeDataArray['dimensionValues'] === [] || $nodeDataArray['dimensionValues'] === '') {
                continue;
            }
            $foundValidDimensionValues = false;
            foreach ($allowedDimensionCombinations as $allowedDimensionConfiguration) {
                ksort($allowedDimensionConfiguration);
                ksort($nodeDataArray['dimensionValues']);
                foreach ($allowedDimensionConfiguration as $allowedDimensionKey => $allowedDimensionValuesArray) {
                    if (isset($nodeDataArray['dimensionValues'][$allowedDimensionKey]) && isset($nodeDataArray['dimensionValues'][$allowedDimensionKey][0])) {
                        $actualDimensionValue = $nodeDataArray['dimensionValues'][$allowedDimensionKey][0];
                        if (in_array($actualDimensionValue, $allowedDimensionValuesArray)) {
                            $foundValidDimensionValues = true;
                            break;
                        }
                    }
                }
            }
            if (!$foundValidDimensionValues) {
                $this->output->outputLine('Node %s has invalid dimension values: %s', [$nodeDataArray['path'], json_encode($nodeDataArray['dimensionValues'])]);
                $nodes[] = $nodeDataArray;
            }
        }
        return $nodes;
    }