Completed
Push — feature/EVO-7278-tracking-info... ( d73a1e...c12eb7 )
by
unknown
66:18
created

DocumentModelListener   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A modelUpdate() 0 4 1
A modelInsert() 0 4 1
A modelDelete() 0 4 1
1
<?php
2
/**
3
 * Custom Model Document listener
4
 */
5
namespace Graviton\AuditTrackingBundle\Listener;
6
7
use Graviton\RestBundle\Event\ModelEvent;
8
use Graviton\AuditTrackingBundle\Manager\ActivityManager;
9
10
/**
11
 * Class DBActivityListener
12
 * @package Graviton\AuditTrackingBundle\Listener
13
 *
14
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
15
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
16
 * @link     http://swisscom.ch
17
 */
18
class DocumentModelListener
19
{
20
    /** @var ActivityManager */
21
    private $manager;
22
23
    /**
24
     * DBActivityListener constructor.
25
     * @param ActivityManager $activityManager Business logic
26
     */
27
    public function __construct(ActivityManager $activityManager)
28
    {
29
        $this->manager = $activityManager;
30
    }
31
32
    /**
33
     * Updating a Model
34
     * @param ModelEvent $event Mongo.odm event argument
35
     * @return void
36
     */
37
    public function modelUpdate(ModelEvent $event)
38
    {
39
        $this->manager->registerDocumentModelEvent($event);
40
    }
41
42
    /**
43
     * Insert a Model
44
     * @param ModelEvent $event Mongo.odm event argument
45
     * @return void
46
     */
47
    public function modelInsert(ModelEvent $event)
48
    {
49
        $this->manager->registerDocumentModelEvent($event);
50
    }
51
52
    /**
53
     * Insert a Model
54
     * @param ModelEvent $event Mongo.odm event argument
55
     * @return void
56
     */
57
    public function modelDelete(ModelEvent $event)
58
    {
59
        $this->manager->registerDocumentModelEvent($event);
60
    }
61
}
62