LP: Add hook when ending learnin path - refs BT#16742

pull/3680/head
Angel Fernando Quiroz Campos 5 years ago
parent 218dbd3c89
commit 688dd4f8db
  1. 29
      main/inc/lib/hook/HookLearningPathEnd.php
  2. 13
      main/inc/lib/hook/interfaces/HookLearningPathEndEventInterface.php
  3. 10
      main/inc/lib/hook/interfaces/HookLearningPathEndObserverInterface.php
  4. 6
      main/lp/learnpath.class.php

@ -0,0 +1,29 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookLearningPathEnd.
*/
class HookLearningPathEnd extends HookEvent implements HookLearningPathEndEventInterface
{
/**
* HookLearningPathEnd constructor.
*
* @throws \Exception
*/
protected function __construct()
{
parent::__construct('HookLearningPathEndEvent');
}
/**
* @inheritDoc
*/
public function hookLearningPathEnd()
{
/** @var \HookLearningPathEndObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->notifyLearningPathEnd($this);
}
}
}

@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookLearningPathEndEventInterface.
*/
interface HookLearningPathEndEventInterface extends HookEventInterface
{
/**
* @return mixed
*/
public function hookLearningPathEnd();
}

@ -0,0 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookLearningPathEndObserverInterface.
*/
interface HookLearningPathEndObserverInterface extends HookObserverInterface
{
public function notifyLearningPathEnd(HookLearningPathEndEventInterface $event);
}

@ -4973,6 +4973,12 @@ class learnpath
error_log($sql);
}
$this->progress_db = $progress;
if (100 == $progress) {
HookLearningPathEnd::create()
->setEventData(['lp_view_id' => $this->lp_view_id])
->hookLearningPathEnd();
}
}
}
}

Loading…
Cancel
Save