/** * @param \Lightwerk\SurfCaptain\Domain\Facet\Deployment\SyncDeployment * @return \Lightwerk\SurfCaptain\Domain\Model\Deployment * @throws \Lightwerk\SurfCaptain\Domain\Repository\Preset\Exception * @throws \Lightwerk\SurfCaptain\GitApi\Exception */ public function createFromSyncDeployment(SyncDeployment $syncDeployment) { $sourcePreset = $this->presetRepository->findByIdentifier($syncDeployment->getSourcePresetKey()); $preset = $this->presetRepository->findByIdentifier($syncDeployment->getPresetKey()); if ($preset['applications'][0]['options']['context'] === 'Production') { throw new Exception('Sync Deployment to Production Context is not allowed.'); } $postset = array(); if (empty($preset['applications'][0]['options']['db']) === TRUE) { $postset['applications'][0]['options']['db']['credentialsSource'] = 'TYPO3\\CMS'; } $postset['applications'][0]['options']['sourceNode'] = $sourcePreset['applications'][0]['nodes'][0]; $postset['applications'][0]['options']['sourceNodeOptions']['deploymentPath'] = $sourcePreset['applications'][0]['options']['deploymentPath']; $postset['applications'][0]['options']['sourceNodeOptions']['context'] = $sourcePreset['applications'][0]['options']['context']; if (empty($sourcePreset['applications'][0]['options']['db']) === TRUE) { $postset['applications'][0]['options']['sourceNodeOptions']['db']['credentialsSource'] = 'TYPO3\\CMS'; } else { $postset['applications'][0]['options']['sourceNodeOptions']['db'] = $sourcePreset['applications'][0]['options']['db']; } $postset['applications'][0]['type'] = $syncDeployment->getDeploymentType(); $configuration = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($preset, $postset); if (empty($configuration['applications'][0]['options']['repositoryUrl']) === TRUE) { $configuration['applications'][0]['options']['repositoryUrl'] = $sourcePreset['applications'][0]['options']['repositoryUrl']; } return $this->createFromConfiguration($configuration); }
/** * @param string $presetKey * @param string $type * @return void */ public function createSyncDeploymentCommand($sourcePresetKey, $targetPresetKey, $type = 'TYPO3\\CMS\\Sync') { $syncDeployment = new SyncDeployment(); $syncDeployment->setSourcePresetKey($sourcePresetKey); $syncDeployment->setPresetKey($targetPresetKey); try { $deployment = $this->deploymentFactory->createFromSyncDeployment($syncDeployment); $this->deploymentRepository->add($deployment); $this->outputLine('OK: deployment added'); } catch (\Lightwerk\SurfCaptain\Exception $e) { $this->outputLine('ERROR: ' . $e->getMessage() . ' - ' . $e->getCode()); } catch (\TYPO3\Flow\Http\Exception $e) { $this->outputLine('ERROR: ' . $e->getMessage() . ' - ' . $e->getCode()); } }