Classes/Command/NodeIndexCommandController.php
public function indexNodeCommand(string $identifier, string $workspace = null): void
    {
        if ($workspace === null && $this->settings['indexAllWorkspaces'] === false) {
            $workspace = 'live';
        }

        $indexNode = function ($identifier, Workspace $workspace, array $dimensions) {
            $context = $this->createContentContext($workspace->getName(), $dimensions);
            $node = $context->getNodeByIdentifier($identifier);
            if ($node === null) {
                $this->outputLine('Node with the given identifier is not found.');
                $this->quit();
            }
            $this->outputLine();
            $this->outputLine('Index node "%s" (%s)', [
                $node->getLabel(),
                $node->getIdentifier(),
            ]);
            $this->outputLine('  workspace: %s', [
                $workspace->getName()
            ]);
            $this->outputLine('  node type: %s', [
                $node->getNodeType()->getName()
            ]);
            $this->outputLine('  dimensions: %s', [
                json_encode($dimensions)
            ]);
            $this->nodeIndexer->indexNode($node);
        };

        $indexInWorkspace = function ($identifier, Workspace $workspace) use ($indexNode) {
            $combinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
            if ($combinations === []) {
                $indexNode($identifier, $workspace, []);
            } else {
                foreach ($combinations as $combination) {
                    $indexNode($identifier, $workspace, $combination);
                }
            }
        };

        if ($workspace === null) {
            foreach ($this->workspaceRepository->findAll() as $workspaceToIndex) {
                $indexInWorkspace($identifier, $workspaceToIndex);
            }
        } else {
            /** @var Workspace $workspaceInstance */
            $workspaceInstance = $this->workspaceRepository->findByIdentifier($workspace);
            if ($workspaceInstance === null) {
                $this->outputLine('The given workspace (%s) does not exist.', [$workspace]);
                $this->quit(1);
            }
            $indexInWorkspace($identifier, $workspaceInstance);
        }
    }
public function indexNodeCommand(string $identifier, string $workspace = null): void
    {
        if ($workspace === null && $this->settings['indexAllWorkspaces'] === false) {
            $workspace = 'live';
        }

        $indexNode = function ($identifier, Workspace $workspace, array $dimensions) {
            $context = $this->createContentContext($workspace->getName(), $dimensions);
            $node = $context->getNodeByIdentifier($identifier);
            if ($node === null) {
                $this->outputLine('Node with the given identifier is not found.');
                $this->quit();
            }
            $this->outputLine();
            $this->outputLine('Index node "%s" (%s)', [
                $node->getLabel(),
                $node->getIdentifier(),
            ]);
            $this->outputLine('  workspace: %s', [
                $workspace->getName()
            ]);
            $this->outputLine('  node type: %s', [
                $node->getNodeType()->getName()
            ]);
            $this->outputLine('  dimensions: %s', [
                json_encode($dimensions)
            ]);
            $this->nodeIndexer->indexNode($node);
        };

        $indexInWorkspace = function ($identifier, Workspace $workspace) use ($indexNode) {
            $combinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
            if ($combinations === []) {
                $indexNode($identifier, $workspace, []);
            } else {
                foreach ($combinations as $combination) {
                    $indexNode($identifier, $workspace, $combination);
                }
            }
        };

        if ($workspace === null) {
            foreach ($this->workspaceRepository->findAll() as $workspaceToIndex) {
                $indexInWorkspace($identifier, $workspaceToIndex);
            }
        } else {
            /** @var Workspace $workspaceInstance */
            $workspaceInstance = $this->workspaceRepository->findByIdentifier($workspace);
            if ($workspaceInstance === null) {
                $this->outputLine('The given workspace (%s) does not exist.', [$workspace]);
                $this->quit(1);
            }
            $indexInWorkspace($identifier, $workspaceInstance);
        }
    }
public function indexNodeCommand ( string $ identifier , string $ workspace = null ) : void { if ( $ workspace === null && $ this -> settings [ 'indexAllWorkspaces' ] === false ) { $ workspace = 'live' ; } $ indexNode = function ( $ identifier , Workspace $ workspace , array $ dimensions ) { $ context = $ this -> createContentContext ( $ workspace -> getName ( ) , $ dimensions ) ; $ node = $ context -> getNodeByIdentifier ( $ identifier ) ; if ( $ node === null ) { $ this -> outputLine ( 'Node with the given identifier is not found.' ) ; $ this -> quit ( ) ; } $ this -> outputLine ( ) ; $ this -> outputLine ( 'Index node "%s" (%s)' , [ $ node -> getLabel ( ) , $ node -> getIdentifier ( ) , ] ) ; $ this -> outputLine ( '  workspace: %s' , [ $ workspace -> getName ( ) ] ) ; $ this -> outputLine ( '  node type: %s' , [ $ node -> getNodeType ( ) -> getName ( ) ] ) ; $ this -> outputLine ( '  dimensions: %s' , [ json_encode ( $ dimensions ) ] ) ; $ this -> nodeIndexer -> indexNode ( $ node ) ; } ; $ indexInWorkspace = function ( $ identifier , Workspace $ workspace ) use ( $ indexNode ) { $ combinations = $ this -> contentDimensionCombinator -> getAllAllowedCombinations ( ) ; if ( $ combinations === [ ] ) { $ indexNode ( $ identifier , $ workspace , [ ] ) ; } else { foreach ( $ combinations as $ combination ) { $ indexNode ( $ identifier , $ workspace , $ combination ) ; } } } ; if ( $ workspace === null ) { foreach ( $ this -> workspaceRepository -> findAll ( ) as $ workspaceToIndex ) { $ indexInWorkspace ( $ identifier , $ workspaceToIndex ) ; } } else { /** @var Workspace $workspaceInstance */ $ workspaceInstance = $ this -> workspaceRepository -> findByIdentifier ( $ workspace ) ; if ( $ workspaceInstance === null ) { $ this -> outputLine ( 'The given workspace (%s) does not exist.' , [ $ workspace ] ) ; $ this -> quit ( 1 ) ; } $ indexInWorkspace ( $ identifier , $ workspaceInstance ) ; } }
Index a single node by the given identifier and workspace name

@param string $identifier
@param string $workspace
@return void
@throws StopActionException
Index a single node by the given identifier and workspace name