ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLSEventHandler Class Reference

Handle events. More...

+ Collaboration diagram for ilLSEventHandler:

Public Member Functions

 __construct (ilTree $tree)
 
 handleObjectDeletion (array $parameter)
 Find out, if a sub object is about to be deleted. More...
 
 handleObjectToTrash (array $parameter)
 
 handleParticipantDeletion (int $obj_id, int $usr_id)
 
 handleClonedObject (ilObject $new_obj, ilObject $origin_obj)
 

Protected Member Functions

 isExistingObject (int $ref_id)
 
 deleteLSOItem (int $obj_ref_id, int $parent_lso_ref_id)
 
 getParentLSOInfo (int $child_ref_id)
 get the LSO up from $child_ref_id More...
 
 getRefIdsOfObjId (int $triggerer_obj_id)
 

Protected Attributes

ilTree $tree
 

Detailed Description

Handle events.

Definition at line 24 of file class.ilLSEventHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilLSEventHandler::__construct ( ilTree  $tree)

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

References $tree.

29  {
30  $this->tree = $tree;
31  }

Member Function Documentation

◆ deleteLSOItem()

ilLSEventHandler::deleteLSOItem ( int  $obj_ref_id,
int  $parent_lso_ref_id 
)
protected

Definition at line 78 of file class.ilLSEventHandler.php.

Referenced by handleObjectDeletion(), and handleObjectToTrash().

78  : void
79  {
80  $lso = $this->getInstanceByRefId($parent_lso_ref_id);
81  $lso->getStateDB()->deleteForItem(
82  $parent_lso_ref_id,
83  $obj_ref_id
84  );
85  }
+ Here is the caller graph for this function:

◆ getParentLSOInfo()

ilLSEventHandler::getParentLSOInfo ( int  $child_ref_id)
protected

get the LSO up from $child_ref_id

Definition at line 112 of file class.ilLSEventHandler.php.

Referenced by handleClonedObject(), handleObjectDeletion(), and handleObjectToTrash().

112  : ?array
113  {
114  if ($child_ref_id === 0) {
115  return null;
116  }
117 
118  foreach ($this->tree->getPathFull($child_ref_id) as $hop) {
119  if ($hop['type'] === 'lso') {
120  return $hop;
121  }
122  }
123  return null;
124  }
+ Here is the caller graph for this function:

◆ getRefIdsOfObjId()

ilLSEventHandler::getRefIdsOfObjId ( int  $triggerer_obj_id)
protected
Returns
array<int|string, int|string>

Definition at line 129 of file class.ilLSEventHandler.php.

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

129  : array
130  {
131  return ilObject::_getAllReferences($triggerer_obj_id);
132  }
static _getAllReferences(int $id)
get all reference ids for object ID
+ Here is the call graph for this function:

◆ handleClonedObject()

ilLSEventHandler::handleClonedObject ( ilObject  $new_obj,
ilObject  $origin_obj 
)

Definition at line 94 of file class.ilLSEventHandler.php.

References getParentLSOInfo(), and ilObject\getRefId().

94  : void
95  {
96  if ($this->getParentLSOInfo($new_obj->getRefId())
97  && $this->getParentLSOInfo($origin_obj->getRefId())
98  ) {
99  $new_lso = $this->getInstanceByRefId(
100  (int) $this->getParentLSOInfo($new_obj->getRefId())['ref_id']
101  );
102  $post_condition_db = $new_lso->getDI()['db.postconditions'];
103  $post_condition = current($post_condition_db->select([$origin_obj->getRefId()]))
104  ->withRefId($new_obj->getRefId());
105  $post_condition_db->upsert([$post_condition]);
106  }
107  }
getParentLSOInfo(int $child_ref_id)
get the LSO up from $child_ref_id
+ Here is the call graph for this function:

◆ handleObjectDeletion()

ilLSEventHandler::handleObjectDeletion ( array  $parameter)

Find out, if a sub object is about to be deleted.

cleanup states.

Definition at line 37 of file class.ilLSEventHandler.php.

References deleteLSOItem(), getParentLSOInfo(), ILIAS\Repository\int(), and isExistingObject().

37  : void
38  {
39  $obj_deleted = $parameter['object'];
40  $obj_ref_id = (int) $obj_deleted->getRefId();
41 
42  if (!$this->isExistingObject($obj_ref_id)) {
43  return;
44  }
45 
46  $parent_lso = $this->getParentLSOInfo($obj_ref_id);
47  if (!is_null($parent_lso)) {
48  $this->deleteLSOItem($obj_ref_id, (int) $parent_lso['ref_id']);
49  }
50  }
getParentLSOInfo(int $child_ref_id)
get the LSO up from $child_ref_id
deleteLSOItem(int $obj_ref_id, int $parent_lso_ref_id)
+ Here is the call graph for this function:

◆ handleObjectToTrash()

ilLSEventHandler::handleObjectToTrash ( array  $parameter)
Parameters
array$parameter[obj_id, ref_id, old_parent_ref_id]

Definition at line 55 of file class.ilLSEventHandler.php.

References deleteLSOItem(), getParentLSOInfo(), ILIAS\Repository\int(), and isExistingObject().

55  : void
56  {
57  $obj_ref_id = (int) $parameter['ref_id'];
58  $old_parent_ref_id = (int) $parameter['old_parent_ref_id'];
59  $parent_lso = $this->getParentLSOInfo($obj_ref_id);
60 
61  if (!$this->isExistingObject($obj_ref_id) || is_null($parent_lso)) {
62  return;
63  }
64 
65  if ($old_parent_ref_id) {
66  $this->deleteLSOItem($obj_ref_id, $old_parent_ref_id);
67  }
68  }
getParentLSOInfo(int $child_ref_id)
get the LSO up from $child_ref_id
deleteLSOItem(int $obj_ref_id, int $parent_lso_ref_id)
+ Here is the call graph for this function:

◆ handleParticipantDeletion()

ilLSEventHandler::handleParticipantDeletion ( int  $obj_id,
int  $usr_id 
)

Definition at line 87 of file class.ilLSEventHandler.php.

87  : void
88  {
89  $lso = $this->getInstanceByObjId($obj_id);
90  $db = $lso->getStateDB();
91  $db->deleteFor($lso->getRefId(), [$usr_id]);
92  }

◆ isExistingObject()

ilLSEventHandler::isExistingObject ( int  $ref_id)
protected

Definition at line 70 of file class.ilLSEventHandler.php.

Referenced by handleObjectDeletion(), and handleObjectToTrash().

70  : bool
71  {
72  if (empty($ref_id) || !$this->tree->isInTree($ref_id)) {
73  return false;
74  }
75  return true;
76  }
$ref_id
Definition: ltiauth.php:67
+ Here is the caller graph for this function:

Field Documentation

◆ $tree

ilTree ilLSEventHandler::$tree
protected

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

Referenced by __construct().


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