protected function collectNodesWithInvalidWorkspace()
    {
        $nodes = [];
        $workspaceNames = [];

        foreach ($this->workspaceRepository->findAll() as $workspace) {
            $workspaceNames[] = $workspace->getName();
        }

        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('n')
            ->from(NodeData::class, 'n')
            ->add('where', $queryBuilder->expr()->orX(
                    $queryBuilder->expr()->notIn('n.workspace', $workspaceNames),
                    $queryBuilder->expr()->isNull('n.workspace')
                )
            );

        foreach ($queryBuilder->getQuery()->getArrayResult() as $nodeDataArray) {
            $this->dispatch(self::EVENT_NOTICE, sprintf('Node <i>%s</i> (identifier: <i>%s</i>) refers to an invalid workspace: <i>%s</i>', $nodeDataArray['path'], $nodeDataArray['identifier'], (isset($nodeDataArray['workspace']) ? $nodeDataArray['workspace'] : 'null')));
            $nodes[] = $nodeDataArray;
        }
        return $nodes;
    }