1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Graham Owens ([email protected]) |
4
|
|
|
* Company: PartFire Ltd (www.partfire.co.uk) |
5
|
|
|
* Console: Discovery |
6
|
|
|
* |
7
|
|
|
* User: gra |
8
|
|
|
* Date: 16/01/17 |
9
|
|
|
* Time: 16:11 |
10
|
|
|
* Project: PartFire MangoPay Bundle |
11
|
|
|
* File: HookCreateAllCommand.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\MangoPayConstants; |
22
|
|
|
use PartFire\MangoPayBundle\Services\Hook; |
23
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
24
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
25
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
26
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
27
|
|
|
use Symfony\Component\Console\Input\InputOption; |
28
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
29
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
30
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
31
|
|
|
|
32
|
|
|
class HookCreateAllCommand extends ContainerAwareCommand |
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
private $output; |
36
|
|
|
|
37
|
|
|
protected function configure() |
38
|
|
|
{ |
39
|
|
|
$this |
40
|
|
|
->setName('partfire:mangopay:hook-create-all') |
41
|
|
|
->setDescription('Points all known hooks to a single endpoint') |
42
|
|
|
; |
43
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
47
|
|
|
{ |
48
|
|
|
$this->output = $this->getConsoleOutPutter(); |
49
|
|
|
$this->output->setOutputer($output); |
50
|
|
|
|
51
|
|
|
//$url = 'http://stage.fruitful.co/'; |
|
|
|
|
52
|
|
|
$url = 'http://138.68.144.130/data-hole.php'; |
53
|
|
|
|
54
|
|
|
$this->output->info("Create all hooks to point to a single end point"); |
55
|
|
|
|
56
|
|
|
foreach (MangoPayConstants::getAllEventTypes() as $eventType) { |
57
|
|
|
$this->output->infoid("Creating end point for " . $eventType); |
58
|
|
|
try { |
59
|
|
|
var_dump($this->getHookService()->create($eventType, $url)); |
|
|
|
|
60
|
|
|
} catch (\Exception $e) { |
61
|
|
|
echo "ERROR - " . $e->getMessage() . "\n"; |
62
|
|
|
} |
63
|
|
|
} |
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
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.