Completed
Pull Request — master (#1093)
by Oleg
07:36
created

PopulateListener::onPostIndexPopulate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
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
        $this->resetter->switchIndexAlias($event->getIndex(), $event->getOption('delete'));
36
    }
37
}
38