From 44d6809bab717f9d0938d531af7417f2562c4406 Mon Sep 17 00:00:00 2001 From: Stefan Matei Date: Mon, 2 Mar 2020 22:10:55 +0200 Subject: [PATCH 1/2] added helper set into context to be used during deployments --- src/Command/DeployCommand.php | 2 +- src/Context.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Command/DeployCommand.php b/src/Command/DeployCommand.php index a3c6a5c..9b5da23 100644 --- a/src/Command/DeployCommand.php +++ b/src/Command/DeployCommand.php @@ -72,7 +72,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output) { $logFilePath = sprintf('%s/deploy_%s.log', $this->logDir, $input->getArgument('stage')); - $context = new Context($input, $output, $this->projectDir, $logFilePath, true === $input->getOption('dry-run'), $output->isVerbose()); + $context = new Context($input, $output, $this->projectDir, $logFilePath, true === $input->getOption('dry-run'), $output->isVerbose(), $this->getHelperSet()); $deployer = include $this->configFilePath; $deployer->initialize($context); diff --git a/src/Context.php b/src/Context.php index 28cd5b4..3f3b7b3 100644 --- a/src/Context.php +++ b/src/Context.php @@ -13,6 +13,8 @@ use EasyCorp\Bundle\EasyDeployBundle\Server\Property; use EasyCorp\Bundle\EasyDeployBundle\Server\Server; +use Symfony\Component\Console\Helper\HelperInterface; +use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -29,8 +31,9 @@ class Context private $output; private $projectDir; private $logFilePath; + private $helperSet; - public function __construct(InputInterface $input, OutputInterface $output, string $projectDir, string $logFilePath, bool $isDryRun, bool $isVerbose) + public function __construct(InputInterface $input, OutputInterface $output, string $projectDir, string $logFilePath, bool $isDryRun, bool $isVerbose, ?HelperSet $helperSet = null) { $this->input = $input; $this->output = $output; @@ -38,6 +41,7 @@ public function __construct(InputInterface $input, OutputInterface $output, stri $this->logFilePath = $logFilePath; $this->dryRun = $isDryRun; $this->debug = $isVerbose; + $this->helperSet = $helperSet; $this->localHost = $this->createLocalHost(); } @@ -87,6 +91,14 @@ public function getOutput(): OutputInterface return $this->output; } + private function getHelper(string $helperName): ?HelperInterface + { + if(!$this->helperSet){ + return null; + } + return $this->helperSet->get($helperName); + } + private function createLocalHost(): Server { $localhost = new Server('localhost'); From 9b3bfb88c2aaa3cacfaa72c3f12841072a7c17ba Mon Sep 17 00:00:00 2001 From: Stefan Matei Date: Mon, 2 Mar 2020 22:21:55 +0200 Subject: [PATCH 2/2] made getHelper method public --- src/Context.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context.php b/src/Context.php index 3f3b7b3..16bb6b6 100644 --- a/src/Context.php +++ b/src/Context.php @@ -91,7 +91,7 @@ public function getOutput(): OutputInterface return $this->output; } - private function getHelper(string $helperName): ?HelperInterface + public function getHelper(string $helperName): ?HelperInterface { if(!$this->helperSet){ return null;