ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 
static handleEvent (string $a_component, string $a_event, array $a_parameter)
 Handle an event in a listener. More...
 

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 49 of file class.ilContainerReferenceAppEventListener.php.

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

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

Referenced by handleEvent().

+ Here is the call graph for this function:
+ Here is the caller 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.

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/Group':
37 case 'components/ILIAS/Category':
38 case 'components/ILIAS/StudyProgramme':
39 switch ($a_event) {
40 case 'delete':
41 $ilLog->write(__METHOD__ . ': Handling delete event.');
42 self::deleteReferences((int) $a_parameter['obj_id']);
43 break;
44 }
45 break;
46 }
47 }

References $DIC, and deleteReferences().

+ Here is the call graph for this function:

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