ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLSLPEventHandler.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
12{
16 protected $tree;
20 protected $lpstatus;
21
25 protected $cached_parent_lso = [];
29 protected $cached_refs_for_obj = [];
30
31
32 public function __construct(
34 ilLPStatusWrapper $lp_status_wrapper
35 ) {
36 $this->tree = $tree;
37 $this->lpstatus = $lp_status_wrapper;
38 }
39
40 public function updateLPForChildEvent(array $parameter)
41 {
42 $refs = $this->getRefIdsOfObjId((int) $parameter['obj_id']);
43 foreach ($refs as $ref_id) {
44 $lso_id = $this->getParentLSOObjId((int) $ref_id);
45 if ($lso_id !== false) {
46 $usr_id = $parameter['usr_id'];
47 $this->lpstatus::_updateStatus($lso_id, $usr_id);
48 }
49 }
50 }
51
56 protected function getParentLSOObjId(int $child_ref_id)
57 {
58 if (!array_key_exists($child_ref_id, $this->cached_parent_lso)) {
59 $this->cached_parent_lso[$child_ref_id] = $this->getParentLSOIdFromTree($child_ref_id);
60 }
61 return $this->cached_parent_lso[$child_ref_id];
62 }
63
64 private function getParentLSOIdFromTree(int $child_ref_id)
65 {
66 $parent_nd = $this->tree->getParentNodeData($child_ref_id);
67 if ($parent_nd['type'] === 'lso') {
68 return $parent_nd['obj_id'];
69 }
70 return false;
71 }
72
73 protected function getRefIdsOfObjId(int $triggerer_obj_id) : array
74 {
75 if (!array_key_exists($triggerer_obj_id, $this->cached_refs_for_obj)) {
76 $this->cached_refs_for_obj[$triggerer_obj_id] = ilObject::_getAllReferences($triggerer_obj_id);
77 }
78 return $this->cached_refs_for_obj[$triggerer_obj_id];
79 }
80}
An exception for terminatinating execution or to throw for unit testing.
Class ilLPStatusWrapper This class is wrapper for all ilLPStatus classes.
__construct(ilTree $tree, ilLPStatusWrapper $lp_status_wrapper)
getParentLSOObjId(int $child_ref_id)
get the LSO up from $child_ref_if
getRefIdsOfObjId(int $triggerer_obj_id)
getParentLSOIdFromTree(int $child_ref_id)
updateLPForChildEvent(array $parameter)
static _getAllReferences($a_id)
get all reference ids of object
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...