Chris@5: siteAlias = $siteAlias; Chris@5: } Chris@5: Chris@5: /** Chris@5: * @inheritdoc Chris@5: */ Chris@5: public function configure(SiteProcess $process) Chris@5: { Chris@5: $this->tty = $process->isTty(); Chris@5: } Chris@5: Chris@5: /** Chris@5: * @inheritdoc Chris@5: */ Chris@5: public function wrap($args) Chris@5: { Chris@5: $transport = $this->getTransport(); Chris@5: $transportOptions = $this->getTransportOptions(); Chris@5: $commandToExecute = $this->getCommandToExecute($args); Chris@5: Chris@5: return array_merge( Chris@5: $transport, Chris@5: $transportOptions, Chris@5: $commandToExecute Chris@5: ); Chris@5: } Chris@5: Chris@5: /** Chris@5: * @inheritdoc Chris@5: */ Chris@5: public function addChdir($cd, $args) Chris@5: { Chris@5: $this->cd_remote = $cd; Chris@5: return $args; Chris@5: } Chris@5: Chris@5: /** Chris@5: * getTransport returns the transport along with the docker-compose Chris@5: * project in case it is defined. Chris@5: */ Chris@5: protected function getTransport() Chris@5: { Chris@5: $transport = ['docker-compose']; Chris@5: $project = $this->siteAlias->get('docker.project', ''); Chris@5: $options = $this->siteAlias->get('docker.compose.options', ''); Chris@5: if ($project && (strpos($options, '-p') === false || strpos($options, '--project') === false)) { Chris@5: $transport = array_merge($transport, ['-p', $project]); Chris@5: } Chris@5: if ($options) { Chris@5: $transport[] = Shell::preEscaped($options); Chris@5: } Chris@5: return array_merge($transport, ['exec']); Chris@5: } Chris@5: Chris@5: /** Chris@5: * getTransportOptions returns the transport options for the tranport Chris@5: * mechanism itself Chris@5: */ Chris@5: protected function getTransportOptions() Chris@5: { Chris@5: $transportOptions = [ Chris@5: $this->siteAlias->get('docker.service', ''), Chris@5: ]; Chris@5: if ($options = $this->siteAlias->get('docker.exec.options', '')) { Chris@5: array_unshift($transportOptions, Shell::preEscaped($options)); Chris@5: } Chris@5: if (!$this->tty) { Chris@5: array_unshift($transportOptions, '-T'); Chris@5: } Chris@5: if ($this->cd_remote) { Chris@5: $transportOptions = array_merge(['--workdir', $this->cd_remote], $transportOptions); Chris@5: } Chris@5: return array_filter($transportOptions); Chris@5: } Chris@5: Chris@5: /** Chris@5: * getCommandToExecute processes the arguments for the command to Chris@5: * be executed such that they are appropriate for the transport mechanism. Chris@5: * Chris@5: * Nothing to do for this transport. Chris@5: */ Chris@5: protected function getCommandToExecute($args) Chris@5: { Chris@5: return $args; Chris@5: } Chris@5: }