ILIAS  release_7 Revision v7.30-3-g800a261c036
CallbackHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
21
22use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
25use ILIAS\HTTP\Wrapper\WrapperFactory;
28
30{
31 use Hasher;
32
33 private const TARGET_SCRIPT = "/ilias.php";
34 public const KEY_ITEM = 'item';
35
39 protected $wrapper;
43 protected $refinery;
47 protected $ctrl;
51 protected $global_screen;
52
53 public function __construct()
54 {
56 global $DIC;
57 $this->ctrl = $DIC->ctrl();
58 $this->wrapper = $DIC->http()->wrapper();
59 $this->refinery = $DIC->refinery();
60 $this->global_screen = $DIC->globalScreen();
61 }
62
63 public function run() : void
64 {
65 $this->ctrl->setTargetScript(self::TARGET_SCRIPT);
66
67 $this->global_screen->collector()
68 ->tool()
69 ->collectOnce();
70
71 $item = $this->global_screen->collector()
72 ->tool()
73 ->getSingleItem($this->getIdentification());
74
75 if ($item instanceof isToolItem) {
76 $callback = $this->resolveCallback($item);
77 $callback();
78 }
79 }
80
81 private function resolveCallback(isToolItem $item) : \Closure
82 {
83 return $item->hasCloseCallback()
84 ? $item->getCloseCallback()
85 : static function () : void {
86 };
87 }
88
90 {
91 $hashed = $this->wrapper->query()->has(self::KEY_ITEM)
92 ? $this->wrapper->query()->retrieve(self::KEY_ITEM, $this->refinery->to()->string())
93 : '';
94
95 $unhashed = $this->unhash($hashed);
96
97 return $this->global_screen->identification()->fromSerializedIdentification($unhashed);
98 }
99}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
ILIAS Initialisation Utility Class perform basic setup: init database handler, load configuration fil...
static initILIAS()
ilias initialisation
global $DIC
Definition: goto.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: gs_content.php:1