Passed
Pull Request — 1.11.x (#4501)
by Angel Fernando Quiroz
10:34
created

PortfolioItemHighlighted::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 27
rs 9.584
cc 1
nc 1
nop 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
use Chamilo\CoreBundle\Entity\PortfolioAttachment;
6
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioItem as PortfolioItemActivity;
7
use Chamilo\PluginBundle\XApi\ToolExperience\Actor\User;
8
use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioAttachmentsTrait;
9
use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioItem as PortfolioItemStatement;
10
use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Highlighted;
11
use Xabbuh\XApi\Model\Statement;
12
13
class PortfolioItemHighlighted extends PortfolioItemStatement
14
{
15
    use PortfolioAttachmentsTrait;
16
17
    public function generate(): Statement
18
    {
19
        $user = api_get_user_entity(api_get_user_id());
20
        $itemAuthor = $this->item->getUser();
21
22
        $itemAttachments = Database::getManager()
23
            ->getRepository(PortfolioAttachment::class)
24
            ->findFromItem($this->item)
25
        ;
26
27
        $actor = new User($user);
28
        $verb = new Highlighted();
29
        $object = new PortfolioItemActivity($this->item);
30
        $context = $this->generateContext();
31
        $attachments = $this->generateAttachments($itemAttachments, $itemAuthor);
32
33
        return new Statement(
34
            $this->generateStatementId('portfolio-item'),
35
            $actor->generate(),
36
            $verb->generate(),
37
            $object->generate(),
38
            null,
39
            null,
40
            api_get_utc_datetime(null, false, true),
41
            null,
42
            $context,
43
            $attachments
44
        );
45
    }
46
}
47