Passed
Pull Request — 1.11.x (#4505)
by Angel Fernando Quiroz
16:24 queued 06:00
created

hookItemDeleted()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 20
rs 9.9332
cc 3
nc 3
nop 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
use Chamilo\CoreBundle\Entity\Portfolio;
6
use Chamilo\PluginBundle\ExternalNotificationConnect\Traits\RequestTrait\RequestTrait;
7
8
class ExternalNotificationConnectPortfolioItemDeletedHookObserver extends ExternalNotificationConnectHookObserver implements HookPortfolioItemDeletedHookObserverInterface
9
{
10
    use RequestTrait;
11
12
    public function hookItemDeleted(HookPortfolioItemDeletedEventInterface $hookEvent)
13
    {
14
        /** @var Portfolio $item */
15
        $item = $hookEvent->getEventData()['item'];
16
17
        try {
18
            $json = $this->doDeleteRequest($item->getId(), 'eportfolio');
19
        } catch (Exception $e) {
20
            Display::addFlash(
21
                Display::return_message($e->getMessage(), 'error')
22
            );
23
24
            return;
25
        }
26
27
        if (empty($json)) {
28
            return;
29
        }
30
31
        error_log('ExtNotifConn: Portfolio item deleted: Status '.((int) $json['status']));
32
    }
33
}
34