1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of CaptainHook. |
4
|
|
|
* |
5
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace CaptainHook\App\Console\Command; |
11
|
|
|
|
12
|
|
|
use CaptainHook\App\CH; |
13
|
|
|
use CaptainHook\App\Runner\Config\Editor; |
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class Add |
21
|
|
|
* |
22
|
|
|
* @package CaptainHook |
23
|
|
|
* @author Sebastian Feldmann <[email protected]> |
24
|
|
|
* @link https://github.com/captainhookphp/captainhook |
25
|
|
|
* @since Class available since Release 4.1.1 |
26
|
|
|
*/ |
27
|
|
|
class Disable extends Base |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Configure the command |
31
|
|
|
* |
32
|
|
|
* @return void |
33
|
|
|
*/ |
34
|
3 |
|
protected function configure() : void |
35
|
|
|
{ |
36
|
3 |
|
$this->setName('disable') |
37
|
3 |
|
->setDescription('Disable a hook execution') |
38
|
3 |
|
->setHelp('This command will disable a hook configuration for a given hook') |
39
|
3 |
|
->addArgument('hook', InputArgument::REQUIRED, 'Hook you want to disable') |
40
|
3 |
|
->addOption( |
41
|
3 |
|
'configuration', |
42
|
3 |
|
'c', |
43
|
3 |
|
InputOption::VALUE_OPTIONAL, |
44
|
3 |
|
'Path to your json configuration', |
45
|
3 |
|
getcwd() . DIRECTORY_SEPARATOR . CH::CONFIG |
46
|
|
|
); |
47
|
3 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Execute the command |
51
|
|
|
* |
52
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
53
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
54
|
|
|
* @return void |
55
|
|
|
* @throws \CaptainHook\App\Exception\InvalidHookName |
56
|
|
|
*/ |
57
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output) : void |
58
|
|
|
{ |
59
|
2 |
|
$io = $this->getIO($input, $output); |
60
|
2 |
|
$config = $this->getConfig($input->getOption('configuration'), true); |
61
|
|
|
|
62
|
1 |
|
$editor = new Editor($io, $config); |
63
|
1 |
|
$editor->setHook((string) $input->getArgument('hook')) |
64
|
1 |
|
->setChange('DisableHook'); |
65
|
|
|
|
66
|
1 |
|
$editor->run(); |
67
|
1 |
|
} |
68
|
|
|
} |
69
|
|
|
|