AppserverIo\Appserver\Core\Api\Node\ProvisionNode::merge PHP Method

merge() public method

This method merges the installation steps of the passed provisioning node into the steps of this instance. If a installation node with the same type already exists, the one of this instance will be overwritten.
public merge ( ProvisionNode $provisionNode ) : void
$provisionNode ProvisionNode The node with the installation steps we want to merge
return void
    public function merge(ProvisionNode $provisionNode)
    {
        // inject the datasource node if available
        if ($datasource = $provisionNode->getDatasource()) {
            $this->injectDatasource($datasource);
        }
        // load the steps of this instance
        $localSteps = $this->getInstallation()->getSteps();
        // merge it with the ones found in the passed provisioning node
        foreach ($provisionNode->getInstallation()->getSteps() as $stepToMerge) {
            foreach ($localSteps as $key => $step) {
                if ($step->getType() === $stepToMerge->getType()) {
                    $localSteps[$key] = $stepToMerge;
                } else {
                    $localSteps[$stepToMerge->getUuid()] = $stepToMerge;
                }
            }
        }
        // set the installation steps
        $this->getInstallation()->setSteps($localSteps);
    }