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
|
|
|
$url = 'http://138.68.144.130/data-hole.php'; |
54
|
|
|
|
55
|
|
|
$responses = []; |
56
|
|
|
|
57
|
|
|
$hookItems = $this->getHookService()->list(); |
58
|
|
|
foreach($hookItems as $hook) { |
59
|
|
|
$hookId = $hook->Id; |
60
|
|
|
$this->output->infoid("Updating Hook ID " . $hookId . " with " . $url); |
61
|
|
|
try { |
62
|
|
|
$responses[] = $this->getHookService()->update($hookId, $url); |
63
|
|
|
} catch (\Exception $e) { |
64
|
|
|
echo "ERROR - " . $e->getMessage() . "\n"; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
var_dump($responses); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
private function showTitle($title) |
72
|
|
|
{ |
73
|
|
|
$this->output->info(str_pad(" " . $title . " ", 80, "-", STR_PAD_BOTH)); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
private function getConsoleOutPutter() : ConsoleOutput |
77
|
|
|
{ |
78
|
|
|
return $this->getContainer()->get('partfire_common.output_console'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
private function getHookService() : Hook |
82
|
|
|
{ |
83
|
|
|
return $this->getContainer()->get('part_fire_mango_pay.services.hook'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
} |