18 declare(strict_types=1);
33 $this->log = $DIC->logger()->wsrv();
53 $this->log->debug(
'ECS cms tree create');
58 $res = $dir_reader->getDirectoryTree($a_content_id);
59 $nodes =
$res->getResult();
65 $this->log->error(
'Tree creation failed with mesage ' . $e->getMessage());
72 $data->setMid($this->mid);
73 $data->setCmsId($cms_tree->rootID);
74 $data->setTreeId($a_content_id);
75 $data->setTitle($cms_tree->directoryTreeTitle);
76 $data->setTerm($cms_tree->term);
80 $tree->insertRootNode($a_content_id,
$data->getObjId());
81 $tree->setRootId(
$data->getObjId());
84 foreach ((array) $cms_tree->nodes as $node) {
88 $data->setMid($this->mid);
89 $data->setCmsId($node->id);
90 $data->setTreeId($a_content_id);
91 $data->setTitle($node->title);
92 $data->setTerm($node->term);
96 if ($node->parent->id) {
103 $tree->insertNode(
$data->getObjId(), $parent_id);
114 $this->log->debug(
'ECS cms tree delete');
118 $data->setMid($this->mid);
119 $data->setTreeId($a_content_id);
138 $this->log->debug(
'ECS cms tree update');
150 $res = $dir_reader->getDirectoryTree($a_content_id);
151 $nodes =
$res->getResult();
156 $this->log->error(
'Tree creation failed with message ' . $e->getMessage());
165 $old_nodes = array();
166 if ($root_node[
'child']) {
167 $old_nodes = $tree->getSubTree($root_node,
true);
171 $this->log->debug(
'Old tree data... ');
198 $data->setMid($this->mid);
199 $data->setCmsId($cms_tree->rootID);
200 $data->setTreeId($a_content_id);
201 $data->setTitle($cms_tree->directoryTreeTitle);
202 $data->setTerm($cms_tree->term);
205 $data->setDeleted(
false);
211 $tree->insertRootNode($a_content_id,
$data->getObjId());
212 $tree->setRootId(
$data->getObjId());
215 foreach ((array) $cms_tree->nodes as $node) {
225 $data->setTitle($node->title);
226 $data->setTerm($node->term);
227 $data->setDeleted(
false);
232 $data->setCmsId($node->id);
233 $data->setMid($this->mid);
235 $data->setTreeId($a_content_id);
236 $data->setDeleted(
false);
239 $data_obj_id =
$data->getObjId();
249 $tree->insertNode(
$data->getObjId(), $parent_id);
259 foreach ($deleted as $obj_id) {
261 foreach ($old_nodes as $node) {
262 if ($node[
'child'] === $obj_id) {
263 $parent = $node[
'parent'];
268 if ($parent && $tree->isInTree($parent)) {
269 $tree->insertNode($obj_id, $parent);
static writeAllDeleted($a_server_id, $a_mid, $a_tree_id, $a_deleted_flag)
Write deleted status.
handleDelete(ilECSSetting $server, int $a_content_id)
Handle delete.
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
getServerId()
Get current server id.
static lookupRootId($a_tree_id)
lookup root id
handleUpdate(ilECSSetting $server, $a_content_id)
Handle update.
static lookupObjId(int $a_server_id, int $a_mid, int $a_tree_id, string $cms_id)
static deleteMappings(int $a_server_id, int $a_mid, int $a_tree_id)
Delete mappings.
Interface for all command queue handler classes.
static findDeletedNodes(int $a_server_id, int $a_mid, int $a_tree_id)
Find deleted nodes Uses a left join since this is more robust.
handleCreate(ilECSSetting $server, $a_content_id)
static deleteByTreeId(int $a_tree_id)
Delete tree by tree_id.
__construct(ilECSSetting $server)