|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
namespace Chamilo\PluginBundle\XApi\ToolExperience\Statement; |
|
6
|
|
|
|
|
7
|
|
|
use Chamilo\CoreBundle\Entity\PortfolioAttachment; |
|
8
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioItem; |
|
|
|
|
|
|
9
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Actor\User; |
|
10
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioItem as PortfolioItemStatement; |
|
11
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Shared; |
|
12
|
|
|
use Database; |
|
13
|
|
|
use Xabbuh\XApi\Model\Statement; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class PortfolioItemShared. |
|
17
|
|
|
* |
|
18
|
|
|
* @package Chamilo\PluginBundle\XApi\ToolExperience\Statement |
|
19
|
|
|
*/ |
|
20
|
|
|
class PortfolioItemShared extends PortfolioItemStatement |
|
21
|
|
|
{ |
|
22
|
|
|
use PortfolioAttachmentsTrait; |
|
23
|
|
|
|
|
24
|
|
|
public function generate(): Statement |
|
25
|
|
|
{ |
|
26
|
|
|
$itemAuthor = $this->item->getUser(); |
|
27
|
|
|
|
|
28
|
|
|
$userActor = new User($itemAuthor); |
|
29
|
|
|
$sharedVerb = new Shared(); |
|
30
|
|
|
$itemActivity = new PortfolioItem($this->item); |
|
31
|
|
|
|
|
32
|
|
|
$context = $this->generateContext(); |
|
33
|
|
|
|
|
34
|
|
|
$itemAttachments = Database::getManager() |
|
35
|
|
|
->getRepository(PortfolioAttachment::class) |
|
36
|
|
|
->findFromItem($this->item) |
|
37
|
|
|
; |
|
38
|
|
|
|
|
39
|
|
|
$attachments = $this->generateAttachments($itemAttachments, $itemAuthor); |
|
40
|
|
|
|
|
41
|
|
|
return new Statement( |
|
42
|
|
|
$this->generateStatementId('portfolio-item'), |
|
43
|
|
|
$userActor->generate(), |
|
44
|
|
|
$sharedVerb->generate(), |
|
45
|
|
|
$itemActivity->generate(), |
|
46
|
|
|
null, |
|
47
|
|
|
null, |
|
48
|
|
|
$this->item->getCreationDate(), |
|
49
|
|
|
null, |
|
50
|
|
|
$context, |
|
51
|
|
|
$attachments |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: