Neos.ContentRepository/Classes/Domain/Model/Node.php
public function createVariantForContext($context): NodeInterface
    {
        $autoCreatedChildNodes = [];
        $nodeType = $this->getNodeType();
        foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
            $childNode = $this->getNode($childNodeName);
            if ($childNode !== null) {
                $autoCreatedChildNodes[$childNodeName] = $childNode;
            }
        }

        $nodeData = new NodeData($this->nodeData->getPath(), $context->getWorkspace(), $this->nodeData->getIdentifier(), $context->getTargetDimensionValues());
        $nodeData->similarize($this->nodeData);

        if ($this->context !== $context) {
            $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
        } else {
            $this->setNodeData($nodeData);
            $node = $this;
        }

        $this->context->getFirstLevelNodeCache()->flush();
        $this->emitNodeAdded($node);

        /**
         * @var $autoCreatedChildNode NodeInterface
         */
        foreach ($autoCreatedChildNodes as $autoCreatedChildNode) {
            $existingChildNode = $node->getNode($autoCreatedChildNode->getName());
            if ($existingChildNode === null || !$existingChildNode->dimensionsAreMatchingTargetDimensionValues()) {
                // only if needed, see https://github.com/neos/neos-development-collection/issues/782
                $autoCreatedChildNode->createVariantForContext($context);
            }
        }

        return $node;
    }
public function createVariantForContext($context): NodeInterface
    {
        $autoCreatedChildNodes = [];
        $nodeType = $this->getNodeType();
        foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
            $childNode = $this->getNode($childNodeName);
            if ($childNode !== null) {
                $autoCreatedChildNodes[$childNodeName] = $childNode;
            }
        }

        $nodeData = new NodeData($this->nodeData->getPath(), $context->getWorkspace(), $this->nodeData->getIdentifier(), $context->getTargetDimensionValues());
        $nodeData->similarize($this->nodeData);

        if ($this->context !== $context) {
            $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
        } else {
            $this->setNodeData($nodeData);
            $node = $this;
        }

        $this->context->getFirstLevelNodeCache()->flush();
        $this->emitNodeAdded($node);

        /**
         * @var $autoCreatedChildNode NodeInterface
         */
        foreach ($autoCreatedChildNodes as $autoCreatedChildNode) {
            $existingChildNode = $node->getNode($autoCreatedChildNode->getName());
            if ($existingChildNode === null || !$existingChildNode->dimensionsAreMatchingTargetDimensionValues()) {
                // only if needed, see https://github.com/neos/neos-development-collection/issues/782
                $autoCreatedChildNode->createVariantForContext($context);
            }
        }

        return $node;
    }
public function createVariantForContext ( $ context ) : NodeInterface { $ autoCreatedChildNodes = [ ] ; $ nodeType = $ this -> getNodeType ( ) ; foreach ( $ nodeType -> getAutoCreatedChildNodes ( ) as $ childNodeName => $ childNodeConfiguration ) { $ childNode = $ this -> getNode ( $ childNodeName ) ; if ( $ childNode !== null ) { $ autoCreatedChildNodes [ $ childNodeName ] = $ childNode ; } } $ nodeData = new NodeData ( $ this -> nodeData -> getPath ( ) , $ context -> getWorkspace ( ) , $ this -> nodeData -> getIdentifier ( ) , $ context -> getTargetDimensionValues ( ) ) ; $ nodeData -> similarize ( $ this -> nodeData ) ; if ( $ this -> context !== $ context ) { $ node = $ this -> nodeFactory -> createFromNodeData ( $ nodeData , $ context ) ; } else { $ this -> setNodeData ( $ nodeData ) ; $ node = $ this ; } $ this -> context -> getFirstLevelNodeCache ( ) -> flush ( ) ; $ this -> emitNodeAdded ( $ node ) ; /**
         * @var $autoCreatedChildNode NodeInterface
         */ foreach ( $ autoCreatedChildNodes as $ autoCreatedChildNode ) { $ existingChildNode = $ node -> getNode ( $ autoCreatedChildNode -> getName ( ) ) ; if ( $ existingChildNode === null || ! $ existingChildNode -> dimensionsAreMatchingTargetDimensionValues ( ) ) { // only if needed, see https://github.com/neos/neos-development-collection/issues/782 $ autoCreatedChildNode -> createVariantForContext ( $ context ) ; } } return $ node ; }
Given a context a new node is returned that is like this node, but
lives in the new context.

@param Context $context
@return NodeInterface
@throws NodeConfigurationException
@throws NodeTypeNotFoundException
Given a context a new node is returned that is like this node but lives in the new context .