easy-deploy-bundle icon indicating copy to clipboard operation
easy-deploy-bundle copied to clipboard

Inject HelperSet in Context

Open stevro opened this issue 5 years ago • 5 comments

I have injected the HelperSet into Context to allow the use of QuestionHelper during the deploy. One use case is when you want the deploy script to ask for a confirmation or from input at runtime.

stevro avatar Mar 02 '20 20:03 stevro

I think this feature is good, but how do we apply the HelperSet for deployment?

fd6130 avatar Nov 12 '21 07:11 fd6130

I'm not sure I understand your question. I attach a sample of code for using it in your deploy:

   $helper = $this->getContext()->getHelperSet('question');

    $question = new ConfirmationQuestion('Continue with this action?', false);

    if (!$helper->ask($this->getContext()->getInput(), $this->getContext()->getOutput(), $question)) {
        $this->log('Exit');
        throw new \Exception('Deployment stopped');
    }

stevro avatar Nov 12 '21 08:11 stevro

I'm not sure I understand your question. I attach a sample of code for using it in your deploy:

   $helper = $this->getContext()->getHelperSet('question');

    $question = new ConfirmationQuestion('Continue with this action?', false);

    if (!$helper->ask($this->getContext()->getInput(), $this->getContext()->getOutput(), $question)) {
        $this->log('Exit');
        throw new \Exception('Deployment stopped');
    }

Cool, that's mean we can use it in some hook method such as beforeFinishingDeploy(). Am i right?

fd6130 avatar Nov 12 '21 08:11 fd6130

Yes. You can use in your deployment scripts where you have access to the context.

stevro avatar Nov 12 '21 08:11 stevro

Yes. You can use in your deployment scripts where you have access to the context.

Thanks. I think i will merge this into my fork instead because this repo not so active in merging PR anymore.

fd6130 avatar Nov 12 '21 08:11 fd6130