/** * Get a deployment object by deployment name * * Looks up the deployment in directory ./.surf/[deploymentName].php * * The script has access to a deployment object as "$deployment". This could change * in the future. * * @param string $deploymentName * @param string $path * @return Deployment * @throws \RuntimeException * @throws InvalidConfigurationException */ protected function createDeployment($deploymentName, $path = null) { $deploymentConfigurationPath = $this->getDeploymentsBasePath($path); $workspacesBasePath = $this->getWorkspacesBasePath(); if (empty($deploymentName)) { $deploymentNames = $this->getDeploymentNames($path); if (count($deploymentNames) !== 1) { throw new InvalidConfigurationException('No deployment name given!', 1451865016); } $deploymentName = array_pop($deploymentNames); } $deploymentPathAndFilename = Files::concatenatePaths(array($deploymentConfigurationPath, $deploymentName . '.php')); if (file_exists($deploymentPathAndFilename)) { $deployment = new Deployment($deploymentName); $deployment->setDeploymentBasePath($deploymentConfigurationPath); $deployment->setWorkspacesBasePath($workspacesBasePath); $tempPath = Files::concatenatePaths(array($workspacesBasePath, $deploymentName)); $this->ensureDirectoryExists($tempPath); $deployment->setTemporaryPath($tempPath); require $deploymentPathAndFilename; } else { $this->createLogger()->error(sprintf("The deployment file %s does not exist.\n", $deploymentPathAndFilename)); $deployment = new FailedDeployment(); } return $deployment; }