ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilContainerReferenceAppEventListener Class Reference

Handles delete events from courses and categories. 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

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, 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  'components/ILIAS/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  }
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupSourceId(int $a_target_id)
$ref_id
Definition: ltiauth.php:65
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: shib_login.php:22
+ 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. "components/ILIAS/Forum" or "components/ILIAS/User"
string$a_eventevent e.g. "createUser", "updateUser", "deleteUser", ...
array<string,mixed>$a_parameter parameter 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 'components/ILIAS/Course':
36  case 'components/ILIAS/Category':
37  case 'components/ILIAS/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: shib_login.php:22

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