Completed
Pull Request — master (#1093)
by Oleg
06:31 queued 02:17
created

PopulateListener::onPostIndexPopulate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
namespace FOS\ElasticaBundle\EventListener;
4
5
use FOS\ElasticaBundle\Event\IndexPopulateEvent;
6
use FOS\ElasticaBundle\Index\Resetter;
7
8
/**
9
 * PopulateListener
10
 *
11
 * @author Oleg Andreyev <[email protected]>
12
 */
13
class PopulateListener
14
{
15
    /**
16
     * @var Resetter
17
     */
18
    private $resetter;
19
20
    /**
21
     * PopulateListener constructor.
22
     *
23
     * @param Resetter $resetter
24
     */
25
    public function __construct(Resetter $resetter)
26
    {
27
        $this->resetter = $resetter;
28
    }
29
30
    /**
31
     * @param IndexPopulateEvent $event
32
     */
33
    public function onPostIndexPopulate(IndexPopulateEvent $event)
34
    {
35
        if (!$event->isReset()) {
36
            return;
37
        }
38
        $this->resetter->switchIndexAlias($event->getIndex(), $event->getOption('delete'));
39
    }
40
}
41