ILIAS  release_8 Revision v8.24
InitCtrlService.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6
8
16final class InitCtrlService
17{
25 public function init(Container $dic): void
26 {
27 $this->abortIfMissingDependencies($dic);
28 $ilias_path = dirname(__FILE__, 5) . '/';
29
30 try {
31 $ctrl_structure = new ilCtrlStructure(
35 );
36 } catch (Throwable $t) {
37 throw new ilCtrlException(self::class . " could not require artifacts, try `composer du` first.");
38 }
39
40 $token_repository = new ilCtrlTokenRepository();
41 $path_factory = new ilCtrlPathFactory($ctrl_structure);
43 $path_factory,
44 $dic->http()->wrapper()->query(),
45 $dic->refinery()
46 );
47
48 // create global instance of ilCtrl
49 $GLOBALS['ilCtrl'] = new ilCtrl(
50 $ctrl_structure,
51 $token_repository,
52 $path_factory,
54 $dic["http.response_sender_strategy"],
55 $dic->http()->request(),
56 $dic->http()->wrapper()->post(),
57 $dic->http()->wrapper()->query(),
58 $dic->refinery(),
59 $dic["component.factory"],
61 );
62
63 // add helper function to DI container that
64 // returns the global instance.
65 $dic['ilCtrl'] = static function () {
66 return $GLOBALS['ilCtrl'];
67 };
68 }
69
78 {
79 if (!$dic->offsetExists('http')) {
80 throw new ilCtrlException("Cannot initialize ilCtrl if HTTP Services are not yet available.");
81 }
82
83 if (!$dic->offsetExists('refinery')) {
84 throw new ilCtrlException("Cannot initialize ilCtrl if Refinery Factory is not yet available.");
85 }
86
87 // if (!$dic->offsetExists('ilDB')) {
88 // throw new ilCtrlException("Cannot initialize ilCtrl if Database is not yet available.");
89 // }
90 }
91}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Class InitCtrlService wraps the initialization of ilCtrl.
init(Container $dic)
Initializes the ilCtrl service.
abortIfMissingDependencies(Container $dic)
Aborts if another dependency required by the ctrl service is not yet available.
Class ilCtrlContext is responsible for holding the current context information.
ilCtrl exceptions
Class ilCtrlPathFactory.
Class ilCtrlStructure holds the currently read control structure.
Class ilCtrlTokenRepository.
Class ilCtrl provides processing control methods.
$dic
Definition: result.php:32
$context
Definition: webdav.php:29