Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 42640af

Browse files
authored
Merge pull request #12 from fd6130/patch
Inject HelperSet in Context
2 parents c7d8d1b + 7780009 commit 42640af

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/Command/DeployCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
7373
protected function execute(InputInterface $input, OutputInterface $output)
7474
{
7575
$logFilePath = sprintf('%s/deploy_%s.log', $this->logDir, $input->getArgument('stage'));
76-
$context = new Context($input, $output, $this->projectDir, $logFilePath, true === $input->getOption('dry-run'), $output->isVerbose());
76+
$context = new Context($input, $output, $this->projectDir, $logFilePath, true === $input->getOption('dry-run'), $output->isVerbose(), $this->getHelperSet());
7777

7878
$deployer = include $this->configFilePath;
7979
$deployer->initialize($context);

src/Context.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use EasyCorp\Bundle\EasyDeployBundle\Server\Property;
1515
use EasyCorp\Bundle\EasyDeployBundle\Server\Server;
16+
use Symfony\Component\Console\Helper\HelperInterface;
17+
use Symfony\Component\Console\Helper\HelperSet;
1618
use Symfony\Component\Console\Input\InputInterface;
1719
use Symfony\Component\Console\Output\OutputInterface;
1820

@@ -29,15 +31,17 @@ class Context
2931
private $output;
3032
private $projectDir;
3133
private $logFilePath;
34+
private $helperSet;
3235

33-
public function __construct(InputInterface $input, OutputInterface $output, string $projectDir, string $logFilePath, bool $isDryRun, bool $isVerbose)
36+
public function __construct(InputInterface $input, OutputInterface $output, string $projectDir, string $logFilePath, bool $isDryRun, bool $isVerbose, ?HelperSet $helperSet = null)
3437
{
3538
$this->input = $input;
3639
$this->output = $output;
3740
$this->projectDir = $projectDir;
3841
$this->logFilePath = $logFilePath;
3942
$this->dryRun = $isDryRun;
4043
$this->debug = $isVerbose;
44+
$this->helperSet = $helperSet;
4145

4246
$this->localHost = $this->createLocalHost();
4347
}
@@ -87,6 +91,14 @@ public function getOutput(): OutputInterface
8791
return $this->output;
8892
}
8993

94+
public function getHelper(string $helperName): ?HelperInterface
95+
{
96+
if(!$this->helperSet){
97+
return null;
98+
}
99+
return $this->helperSet->get($helperName);
100+
}
101+
90102
private function createLocalHost(): Server
91103
{
92104
$localhost = new Server('localhost');

0 commit comments

Comments
 (0)