1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Conveyor package. |
5
|
|
|
* |
6
|
|
|
* (c) Jeroen Fiege <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Webcreate\Conveyor\Subscriber; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
15
|
|
|
use Webcreate\Conveyor\IO\IOInterface; |
16
|
|
|
use Webcreate\Vcs\Common\Event\Data\CheckoutEventData; |
17
|
|
|
use Webcreate\Vcs\Common\Event\Data\ExportEventData; |
18
|
|
|
use Webcreate\Vcs\Common\Event\VcsEvent; |
19
|
|
|
use Webcreate\Vcs\Common\VcsEvents; |
20
|
|
|
|
21
|
|
|
class VcsSubscriber implements EventSubscriberInterface |
22
|
|
|
{ |
23
|
|
|
protected $io; |
|
|
|
|
24
|
|
|
|
25
|
1 |
|
public function __construct(IOInterface $io) |
|
|
|
|
26
|
|
|
{ |
27
|
1 |
|
$this->io = $io; |
28
|
1 |
|
} |
29
|
|
|
|
30
|
1 |
|
public static function getSubscribedEvents() |
31
|
|
|
{ |
32
|
|
|
return array( |
33
|
1 |
|
VcsEvents::PRE_CHECKOUT => array('onVcsPreCheckout'), |
34
|
1 |
|
VcsEvents::PRE_EXPORT => array('onVcsPreExport'), |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
View Code Duplication |
public function onVcsPreCheckout(VcsEvent $event) |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
if (false === $this->io->isVerbose()) return; |
|
|
|
|
41
|
|
|
|
42
|
|
|
/** @var CheckoutEventData $data */ |
43
|
|
|
$data = $event->getData(); |
44
|
|
|
|
45
|
|
|
$this->io->write( |
46
|
|
|
sprintf( |
47
|
|
|
'Checking out <comment>%s</comment> to <comment>%s</comment>...' |
48
|
|
|
, |
|
|
|
|
49
|
|
|
$data->getHead()->getName(), |
50
|
|
|
$data->getDestination() |
51
|
|
|
) |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
View Code Duplication |
public function onVcsPreExport(VcsEvent $event) |
|
|
|
|
56
|
|
|
{ |
57
|
|
|
if (false === $this->io->isVerbose()) return; |
|
|
|
|
58
|
|
|
|
59
|
|
|
/** @var ExportEventData $data */ |
60
|
|
|
$data = $event->getData(); |
61
|
|
|
|
62
|
|
|
$this->io->write( |
63
|
|
|
sprintf( |
64
|
|
|
'Exporting <comment>%s</comment> to <comment>%s</comment>...' |
65
|
|
|
, |
|
|
|
|
66
|
|
|
$data->getHead()->getName(), |
67
|
|
|
$data->getDestination() |
68
|
|
|
) |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.