1 | <?php |
||
28 | abstract class CloudCommand extends ContainerAwareCommand |
||
29 | { |
||
30 | /** |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | 85 | protected function configure() |
|
34 | { |
||
35 | 85 | $this->setName(static::$defaultName); // BC with Symfony Console 3.3 and older not handling the property automatically |
|
36 | 85 | $this->addOption( |
|
37 | 85 | 'cloud', |
|
38 | 85 | '-c', |
|
39 | 85 | InputOption::VALUE_REQUIRED, |
|
40 | 85 | 'Cloud on which the command is executed.' |
|
41 | ); |
||
42 | 85 | } |
|
43 | |||
44 | /** |
||
45 | * @return \Xabbuh\PandaClient\Api\CloudManager |
||
46 | */ |
||
47 | 67 | protected function getCloudManager() |
|
48 | { |
||
49 | 67 | return $this->getContainer()->get('xabbuh_panda.cloud_manager'); |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get the cloud to work on. |
||
54 | * |
||
55 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
56 | * |
||
57 | * @return \Xabbuh\PandaClient\Api\CloudInterface |
||
58 | */ |
||
59 | 67 | protected function getCloud(InputInterface $input) |
|
60 | { |
||
61 | 67 | if (null === $input->getOption('cloud')) { |
|
62 | 67 | return $this->getCloudManager()->getDefaultCloud(); |
|
63 | } |
||
64 | |||
65 | return $this->getCloudManager()->getCloud($input->getOption('cloud')); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Executes the actual command (to be implemented by subclasses, will be called automatically). |
||
70 | * |
||
71 | * @param InputInterface $input |
||
72 | * @param OutputInterface $output |
||
73 | */ |
||
74 | abstract protected function doExecuteCommand(InputInterface $input, OutputInterface $output); |
||
75 | |||
76 | /** |
||
77 | * {@inheritDoc} |
||
78 | */ |
||
79 | 69 | protected function execute(InputInterface $input, OutputInterface $output) |
|
91 | } |
||
92 |