ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilContainerReferenceAppEventListener Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilContainerReferenceAppEventListener:
+ Collaboration diagram for ilContainerReferenceAppEventListener:

Static Public Member Functions

static handleEvent (string $a_component, string $a_event, array $a_parameter)
 Handle an event in a listener. More...
 
static deleteReferences (int $a_target_id)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Handles delete events from courses and categories.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilContainerReferenceAppEventListener.php.

Member Function Documentation

◆ deleteReferences()

static ilContainerReferenceAppEventListener::deleteReferences ( int  $a_target_id)
static

Definition at line 48 of file class.ilContainerReferenceAppEventListener.php.

References $DIC, $ref_id, $type, ilObject\_getAllReferences(), ilContainerReference\_lookupSourceId(), and ilObjectFactory\getInstanceByRefId().

48  : void
49  {
50  global $DIC;
51 
52  $ilLog = $DIC["ilLog"];
53  $ilAppEventHandler = $DIC["ilAppEventHandler"];
54  $tree = $DIC["tree"];
55 
56  if (!$source_id = ilContainerReference::_lookupSourceId($a_target_id)) {
57  return;
58  }
59  foreach (ilObject::_getAllReferences($source_id) as $ref_id) {
60  if (!$instance = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
61  continue;
62  }
63  $type = $instance->getType();
64  switch ($type) {
65  case 'grpr':
66  case 'crsr':
67  case 'catr':
68  case 'prgr':
69  $parent_id = $tree->getParentId($ref_id);
70  $instance->delete();
71  $ilLog->write(__METHOD__ . ': Deleted reference object of type ' . $instance->getType() . ' with Id ' . $instance->getId());
72  $ilAppEventHandler->raise(
73  'Services/ContainerReference',
74  'deleteReference',
75  [
76  'ref_id' => $ref_id,
77  'old_parent_ref_id' => $parent_id,
78  'type' => $type
79  ]
80  );
81  break;
82 
83  default:
84  $ilLog->write(__METHOD__ . ': Unexpected object type ' . $instance->getType() . ' with Id ' . $instance->getId());
85  break;
86  }
87  }
88  }
$type
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupSourceId(int $a_target_id)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ handleEvent()

static ilContainerReferenceAppEventListener::handleEvent ( string  $a_component,
string  $a_event,
array  $a_parameter 
)
static

Handle an event in a listener.

Parameters
string$a_componentcomponent, e.g. "Modules/Forum" or "Services/User"
string$a_eventevent e.g. "createUser", "updateUser", "deleteUser", ...
array$a_parameterparameter array (assoc), array("name" => ..., "phone_office" => ...)

Implements ilAppEventListener.

Definition at line 28 of file class.ilContainerReferenceAppEventListener.php.

References $DIC.

28  : void
29  {
30  global $DIC;
31 
32  $ilLog = $DIC["ilLog"];
33 
34  switch ($a_component) {
35  case 'Modules/Course':
36  case 'Modules/Category':
37  case 'Modules/StudyProgramme':
38  switch ($a_event) {
39  case 'delete':
40  $ilLog->write(__METHOD__ . ': Handling delete event.');
41  self::deleteReferences((int) $a_parameter['obj_id']);
42  break;
43  }
44  break;
45  }
46  }
global $DIC
Definition: feed.php:28

The documentation for this class was generated from the following file: