ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.LayoutTemplateCommandActionHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
26class LayoutTemplateCommandActionHandler implements Server\CommandActionHandler
27{
28 protected \ILIAS\DI\UIServices $ui;
29 protected \ilLanguage $lng;
30 protected \ilPageObjectGUI $page_gui;
31 protected \ilObjUser $user;
32 protected Server\UIWrapper $ui_wrapper;
33
35 {
36 global $DIC;
37
38 $this->ui = $DIC->ui();
39 $this->lng = $DIC->language();
40 $this->page_gui = $page_gui;
41 $this->user = $DIC->user();
42
43 $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
44 }
45
46 public function handle(array $query, array $body): Server\Response
47 {
48 switch ($body["action"]) {
49 case "insert":
50 return $this->insertCommand($body);
51
52 default:
53 throw new Exception("Unknown action " . $body["action"]);
54 }
55 }
56
57 protected function insertCommand(array $body): Server\Response
58 {
59 $page = $this->page_gui->getPageObject();
60
61 $hier_id = "pg";
62 $pc_id = "";
63 if (!in_array($body["after_pcid"], ["", "pg"])) {
64 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
65 $hier_id = $hier_ids[$body["after_pcid"]];
66 $pc_id = $body["after_pcid"];
67 }
68
69 $lay = new \ilPCLayoutTemplate($page);
70 $lay->create($page, $hier_id, $pc_id, (int) $body["tmpl"]);
71 $updated = $page->update();
72
73 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
74 }
75}
Page editor json server.
Class ilPageObjectGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26