1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GBProd\ElasticsearchDataProviderBundle\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
6
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
7
|
|
|
use GBProd\ElasticsearchDataProviderBundle\Event\HasStartedHandling; |
8
|
|
|
use GBProd\ElasticsearchDataProviderBundle\Event\HasStartedProviding; |
9
|
|
|
use GBProd\ElasticsearchDataProviderBundle\Event\HasIndexingDocument; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Progress bar for providing |
13
|
|
|
* |
14
|
|
|
* @author gbprod <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class ProvidingProgressBar |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var OutputInterface |
20
|
|
|
*/ |
21
|
|
|
private $output; |
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param EventDispatcherInterface $dispatcher |
25
|
|
|
* @param OutputInterface $output |
26
|
|
|
*/ |
27
|
1 |
|
public function __construct( |
28
|
|
|
EventDispatcherInterface $dispatcher, |
29
|
|
|
OutputInterface $output |
30
|
|
|
) { |
31
|
1 |
|
$dispatcher->addListener( |
32
|
1 |
|
'elasticsearch.has_started_handling', |
33
|
|
|
function (HasStartedHandling $event) use ($output) { |
34
|
|
|
$output->writeln(sprintf( |
35
|
|
|
'<info>Start running <comment>%d</comment> providers</info>', |
36
|
|
|
count($event->getEntries()) |
37
|
|
|
)); |
38
|
|
|
} |
39
|
1 |
|
); |
40
|
|
|
|
41
|
1 |
|
$dispatcher->addListener( |
42
|
1 |
|
'elasticsearch.has_started_providing', |
43
|
|
|
function (HasStartedProviding $event) use ($output) { |
44
|
|
|
$output->writeln(sprintf( |
45
|
|
|
'<info>Start running <comment>%s</comment> provider</info>', |
46
|
|
|
get_class($event->getEntry()->getProvider()) |
47
|
1 |
|
)); |
48
|
|
|
} |
49
|
1 |
|
); |
50
|
|
|
|
51
|
1 |
|
$dispatcher->addListener( |
52
|
1 |
|
'elasticsearch.has_indexed_document', |
53
|
|
|
function (HasIndexingDocument $event) use ($output) { |
54
|
|
|
$output->writeln(sprintf( |
55
|
|
|
'<info>Indexing <comment>%s</comment> document</info>', |
56
|
|
|
get_class($event->getEntry()->getId()) |
57
|
|
|
)); |
58
|
|
|
} |
59
|
1 |
|
); |
60
|
|
|
} |
61
|
|
|
} |
This check marks private properties in classes that are never used. Those properties can be removed.