Completed
Pull Request — 1.4 (#683)
by Paweł
08:30
created

TimestampableListener::updateField()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Content Bundle.
7
 *
8
 * Copyright 2018 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2018 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\ContentBundle\EventListener;
18
19
use SWP\Bundle\ContentBundle\Doctrine\TimestampableCancelInterface;
20
use Gedmo\Timestampable\TimestampableListener as GedmoTimestampableListener;
21
22
class TimestampableListener extends GedmoTimestampableListener
23
{
24
    protected function updateField($object, $eventAdapter, $meta, $field)
25
    {
26
        if (!$this->isTimestampableCanceled($object)) {
27
            parent::updateField($object, $eventAdapter, $meta, $field);
28
        }
29
    }
30
31
    private function isTimestampableCanceled($object): bool
32
    {
33
        if (!$object instanceof TimestampableCancelInterface) {
34
            return false;
35
        }
36
37
        return $object->isTimestampableCanceled();
38
    }
39
}
40