1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Alcalyn\PayplugBundle\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6
|
|
|
use Symfony\Component\Console\Input\InputOption; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
use Alcalyn\PayplugBundle\Exceptions\PayplugException; |
10
|
|
|
|
11
|
|
|
class AccountLoaderCommand extends ContainerAwareCommand |
12
|
|
|
{ |
13
|
|
|
protected function configure() |
14
|
|
|
{ |
15
|
|
|
$this |
16
|
|
|
->setName('payplug:account:update') |
17
|
|
|
->setDescription('Update your Payplug account parameters and set them into your parameters.yml') |
18
|
|
|
->addOption('test', null, InputOption::VALUE_NONE, 'Load test environment') |
19
|
|
|
->addOption('no-prod', null, InputOption::VALUE_NONE, 'Do not load prod environment again') |
20
|
|
|
; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
24
|
|
|
{ |
25
|
|
|
$dialog = $this->getHelperSet()->get('dialog'); |
26
|
|
|
|
27
|
|
|
$output->writeLn(''); |
28
|
|
|
|
29
|
|
|
$mail = $dialog->ask( |
30
|
|
|
$output, |
31
|
|
|
'Payplug account mail: ' |
32
|
|
|
); |
33
|
|
|
|
34
|
|
|
$pass = $dialog->askHiddenResponse( |
35
|
|
|
$output, |
36
|
|
|
'Payplug account pass: ' |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
try { |
40
|
|
|
$output->writeLn(''); |
41
|
|
|
$payplugAccountLoader = $this->getContainer()->get('payplug.account_loader'); |
42
|
|
|
|
43
|
|
|
if ($input->getOption('test')) { |
44
|
|
|
$output->write('Load TEST account parameters... '); |
45
|
|
|
} else { |
46
|
|
|
$output->write('Load account parameters... '); |
47
|
|
|
} |
48
|
|
|
$payplugAccountLoader->loadPayplugParameters( |
49
|
|
|
$mail, |
50
|
|
|
$pass, |
51
|
|
|
$input->getOption('test'), |
52
|
|
|
$input->getOption('no-prod') |
53
|
|
|
); |
54
|
|
|
$output->writeLn('[OK]'); |
55
|
|
|
|
56
|
|
|
$output->writeLn(''); |
57
|
|
|
$output->writeLn('[OK] Parameters successfully loaded.'); |
58
|
|
|
} catch (PayplugException $e) { |
59
|
|
|
$output->writeLn('[FAIL] '.$e->getMessage()); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|