Passed
Pull Request — 1.11.x (#4368)
by Angel Fernando Quiroz
08:24
created

hookItemViewed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
use Chamilo\CoreBundle\Entity\Portfolio;
6
use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioItemViewed;
7
use Doctrine\ORM\OptimisticLockException;
8
use Doctrine\ORM\ORMException;
9
10
class XApiPortfolioItemViewedHookObserver extends XApiActivityHookObserver implements
11
    HookPortfolioItemViewedObserverInterface
12
{
13
    /**
14
     * @throws OptimisticLockException
15
     * @throws ORMException
16
     */
17
    public function hookItemViewed(HookPortfolioItemViewedEventInterface $hookEvent)
18
    {
19
        /** @var Portfolio $item */
20
        $item = $hookEvent->getEventData()['portfolio'];
21
22
        $statement = (new PortfolioItemViewed($item))->generate();
23
24
        $this->saveSharedStatement($statement);
25
    }
26
}
27