Passed
Push — master ( d7dc61...397ecf )
by
unknown
02:26
created

HookUpdateAllCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * Created by Graham Owens ([email protected])
4
 * Company: PartFire Ltd (www.partfire.co.uk)
5
 * Console: Relativity
6
 *
7
 * User:    gra
8
 * Date:    16/01/2017
9
 * Time:    23:07
10
 * Project: PartFire MangoPay Bundle
11
 * File:    HookUpdateAllCommand.php
12
 *
13
 **/
14
15
namespace PartFire\MangoPayBundle\Command;
16
17
use Fruitful\IdentityCheckBundle\Entity\IdentityCheck;
18
use Fruitful\IdentityCheckBundle\Entity\Repository\IdentityCheckFactoryRepository;
19
use Fruitful\IdentityCheckBundle\Event\IdentityCheckUpdateEvent;
20
use PartFire\CommonBundle\Services\Output\Cli\ConsoleOutput;
21
use PartFire\MangoPayBundle\Services\Hook;
22
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
23
use Symfony\Component\Console\Input\InputArgument;
24
use Symfony\Component\Console\Input\InputDefinition;
25
use Symfony\Component\Console\Input\InputInterface;
26
use Symfony\Component\Console\Input\InputOption;
27
use Symfony\Component\Console\Output\OutputInterface;
28
use Symfony\Component\EventDispatcher\EventDispatcher;
29
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
30
31
class HookUpdateAllCommand extends ContainerAwareCommand
32
{
33
34
    private $output;
35
36
    protected function configure()
37
    {
38
        $this
39
            ->setName('partfire:mangopay:hook-update-all')
40
            ->setDescription('Update all hook urls')
41
        ;
42
43
    }
44
45
    protected function execute(InputInterface $input, OutputInterface $output)
46
    {
47
        $this->output = $this->getConsoleOutPutter();
48
        $this->output->setOutputer($output);
49
50
        $this->output->info("Listing all hooks with MangoPay");
51
52
        $url = 'https://stage.fruitful.co/updated';
53
54
        $responses = [];
55
56
        $hookItems = $this->getHookService()->list();
57
        foreach($hookItems as $hook) {
58
            $hookId = $hook->Id;
59
            $this->output->infoid("Updating Hook ID " . $hookId . " with " . $url);
60
            $responses[] = $this->getHookService()->update($hookId, $url);
61
        }
62
63
        var_dump($responses);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($responses); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
64
    }
65
66
    private function showTitle($title)
67
    {
68
        $this->output->info(str_pad(" " . $title . " ", 80, "-", STR_PAD_BOTH));
69
    }
70
71
    private function getConsoleOutPutter() : ConsoleOutput
72
    {
73
        return $this->getContainer()->get('partfire_common.output_console');
74
    }
75
76
    private function getHookService() : Hook
77
    {
78
        return $this->getContainer()->get('part_fire_mango_pay.services.hook');
79
    }
80
81
}