parent
e796cf1925
commit
51e83db2b9
@ -0,0 +1,19 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
class HookPortfolioItemHighlighted extends HookEvent implements HookPortfolioItemHighlightedEventInterface |
||||
{ |
||||
protected function __construct() |
||||
{ |
||||
parent::__construct('HookPortfolioItemHighlighted'); |
||||
} |
||||
|
||||
public function notifyItemHighlighted() |
||||
{ |
||||
/** @var HookPortfolioItemHighlightedObserverInterface $observer */ |
||||
foreach ($this->observers as $observer) { |
||||
$observer->hookItemHighlighted($this); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
interface HookPortfolioItemHighlightedEventInterface extends HookEventInterface |
||||
{ |
||||
public function notifyItemHighlighted(); |
||||
} |
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
interface HookPortfolioItemHighlightedObserverInterface extends HookObserverInterface |
||||
{ |
||||
public function hookItemHighlighted(HookPortfolioItemHighlightedEventInterface $hookEvent); |
||||
} |
||||
@ -0,0 +1,22 @@ |
||||
<?php |
||||
|
||||
use Chamilo\CoreBundle\Entity\Portfolio; |
||||
use Doctrine\ORM\OptimisticLockException; |
||||
use Doctrine\ORM\ORMException; |
||||
|
||||
class XApiPortfolioItemHighlightedHookObserver extends XApiActivityHookObserver implements HookPortfolioItemHighlightedObserverInterface |
||||
{ |
||||
/** |
||||
* @throws OptimisticLockException |
||||
* @throws ORMException |
||||
*/ |
||||
public function hookItemHighlighted(HookPortfolioItemHighlightedEventInterface $hookEvent) |
||||
{ |
||||
/** @var Portfolio $item */ |
||||
$item = $hookEvent->getEventData()['item']; |
||||
|
||||
$statement = (new PortfolioItemHighlighted($item))->generate(); |
||||
|
||||
$this->saveSharedStatement($statement); |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use Chamilo\CoreBundle\Entity\PortfolioAttachment; |
||||
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioItem as PortfolioItemActivity; |
||||
use Chamilo\PluginBundle\XApi\ToolExperience\Actor\User; |
||||
use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioAttachmentsTrait; |
||||
use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioItem as PortfolioItemStatement; |
||||
use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Highlighted; |
||||
use Xabbuh\XApi\Model\Statement; |
||||
|
||||
class PortfolioItemHighlighted extends PortfolioItemStatement |
||||
{ |
||||
use PortfolioAttachmentsTrait; |
||||
|
||||
public function generate(): Statement |
||||
{ |
||||
$user = api_get_user_entity(api_get_user_id()); |
||||
$itemAuthor = $this->item->getUser(); |
||||
|
||||
$itemAttachments = Database::getManager() |
||||
->getRepository(PortfolioAttachment::class) |
||||
->findFromItem($this->item) |
||||
; |
||||
|
||||
$actor = new User($user); |
||||
$verb = new Highlighted(); |
||||
$object = new PortfolioItemActivity($this->item); |
||||
$context = $this->generateContext(); |
||||
$attachments = $this->generateAttachments($itemAttachments, $itemAuthor); |
||||
|
||||
return new Statement( |
||||
$this->generateStatementId('portfolio-item'), |
||||
$actor->generate(), |
||||
$verb->generate(), |
||||
$object->generate(), |
||||
null, |
||||
null, |
||||
api_get_utc_datetime(null, false, true), |
||||
null, |
||||
$context, |
||||
$attachments |
||||
); |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\XApi\ToolExperience\Verb; |
||||
|
||||
class Highlighted extends BaseVerb |
||||
{ |
||||
public function __construct() |
||||
{ |
||||
parent::__construct( |
||||
'http://id.tincanapi.com/verb/promoted', |
||||
'Highlighted' |
||||
); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue