Completed
Pull Request — master (#660)
by
unknown
02:31
created

DocumentIdsListener::onESPostCommit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\ElasticsearchBundle\EventListener;
13
14
use ONGR\ElasticsearchBundle\Event\CommitEvent;
15
use ONGR\ElasticsearchBundle\Event\PersistEvent;
16
use ONGR\ElasticsearchBundle\Service\IdSetter;
17
18
class DocumentIdsListener
19
{
20
    /**
21
     * @var IdSetter $setter
22
     */
23
    private $setter;
24
25
    /**
26
     * @param IdSetter $setter
27
     */
28
    public function __construct(IdSetter $setter)
29
    {
30
        $this->setter = $setter;
31
    }
32
33
    /**
34
     * @param PersistEvent $event
35
     */
36
    public function onEsPersist(PersistEvent $event)
37
    {
38
        $this->setter->persist($event->getDocument());
39
    }
40
41
42
    public function onESPostCommit(CommitEvent $event)
43
    {
44
        $this->setter->addIds($event->getBulkParams());
45
    }
46
}
47