Neos.ContentRepository/Classes/Domain/Model/Workspace.php
public function publishNode(NodeInterface $nodeToPublish, Workspace $targetWorkspace)
    {
        if ($this->publishNodeCanBeSkipped($nodeToPublish, $targetWorkspace)) {
            return;
        }
        $this->emitBeforeNodePublishing($nodeToPublish, $targetWorkspace);

        $correspondingNodeDataInTargetWorkspace = $this->findCorrespondingNodeDataInTargetWorkspace($nodeToPublish, $targetWorkspace);
        $matchingNodeVariantExistsInTargetWorkspace = ($correspondingNodeDataInTargetWorkspace !== null && $correspondingNodeDataInTargetWorkspace->getDimensionValues() === $nodeToPublish->getDimensions());

        // Save the original node workspace because the workspace of $nodeToPublish can be changed by replaceNodeData():
        $originalNodeWorkspace = $nodeToPublish->getWorkspace();

        if ($matchingNodeVariantExistsInTargetWorkspace) {
            $this->replaceNodeData($nodeToPublish, $correspondingNodeDataInTargetWorkspace);
            $this->moveNodeVariantsInOtherWorkspaces($nodeToPublish->getIdentifier(), $nodeToPublish->getPath(), $originalNodeWorkspace, $targetWorkspace);
        } else {
            $this->moveNodeVariantToTargetWorkspace($nodeToPublish, $targetWorkspace);
        }

        $this->emitAfterNodePublishing($nodeToPublish, $targetWorkspace);
    }
public function publishNode(NodeInterface $nodeToPublish, Workspace $targetWorkspace)
    {
        if ($this->publishNodeCanBeSkipped($nodeToPublish, $targetWorkspace)) {
            return;
        }
        $this->emitBeforeNodePublishing($nodeToPublish, $targetWorkspace);

        $correspondingNodeDataInTargetWorkspace = $this->findCorrespondingNodeDataInTargetWorkspace($nodeToPublish, $targetWorkspace);
        $matchingNodeVariantExistsInTargetWorkspace = ($correspondingNodeDataInTargetWorkspace !== null && $correspondingNodeDataInTargetWorkspace->getDimensionValues() === $nodeToPublish->getDimensions());

        // Save the original node workspace because the workspace of $nodeToPublish can be changed by replaceNodeData():
        $originalNodeWorkspace = $nodeToPublish->getWorkspace();

        if ($matchingNodeVariantExistsInTargetWorkspace) {
            $this->replaceNodeData($nodeToPublish, $correspondingNodeDataInTargetWorkspace);
            $this->moveNodeVariantsInOtherWorkspaces($nodeToPublish->getIdentifier(), $nodeToPublish->getPath(), $originalNodeWorkspace, $targetWorkspace);
        } else {
            $this->moveNodeVariantToTargetWorkspace($nodeToPublish, $targetWorkspace);
        }

        $this->emitAfterNodePublishing($nodeToPublish, $targetWorkspace);
    }
public function publishNode ( NodeInterface $ nodeToPublish , Workspace $ targetWorkspace ) { if ( $ this -> publishNodeCanBeSkipped ( $ nodeToPublish , $ targetWorkspace ) ) { return ; } $ this -> emitBeforeNodePublishing ( $ nodeToPublish , $ targetWorkspace ) ; $ correspondingNodeDataInTargetWorkspace = $ this -> findCorrespondingNodeDataInTargetWorkspace ( $ nodeToPublish , $ targetWorkspace ) ; $ matchingNodeVariantExistsInTargetWorkspace = ( $ correspondingNodeDataInTargetWorkspace !== null && $ correspondingNodeDataInTargetWorkspace -> getDimensionValues ( ) === $ nodeToPublish -> getDimensions ( ) ) ; // Save the original node workspace because the workspace of $nodeToPublish can be changed by replaceNodeData(): $ originalNodeWorkspace = $ nodeToPublish -> getWorkspace ( ) ; if ( $ matchingNodeVariantExistsInTargetWorkspace ) { $ this -> replaceNodeData ( $ nodeToPublish , $ correspondingNodeDataInTargetWorkspace ) ; $ this -> moveNodeVariantsInOtherWorkspaces ( $ nodeToPublish -> getIdentifier ( ) , $ nodeToPublish -> getPath ( ) , $ originalNodeWorkspace , $ targetWorkspace ) ; } else { $ this -> moveNodeVariantToTargetWorkspace ( $ nodeToPublish , $ targetWorkspace ) ; } $ this -> emitAfterNodePublishing ( $ nodeToPublish , $ targetWorkspace ) ; }
Publishes the given node to the target workspace.

The specified workspace must be a base workspace of this workspace.

@param NodeInterface $nodeToPublish The node to publish
@param Workspace $targetWorkspace The workspace to publish to
@return void
@api
Publishes the given node to the target workspace .