ILIAS  release_8 Revision v8.24
InitCtrlService Class Reference

Class InitCtrlService wraps the initialization of ilCtrl. More...

+ Collaboration diagram for InitCtrlService:

Public Member Functions

 init (Container $dic)
 Initializes the ilCtrl service. More...
 

Private Member Functions

 abortIfMissingDependencies (Container $dic)
 Aborts if another dependency required by the ctrl service is not yet available. More...
 

Detailed Description

Class InitCtrlService wraps the initialization of ilCtrl.

Author
Thibeau Fuhrer thf@s.nosp@m.tude.nosp@m.r-rai.nosp@m.mann.nosp@m..ch This class exists because due to dependency-injection the initialization of ilCtrl got a little more complicated - and is used on several occasions.

Definition at line 16 of file InitCtrlService.php.

Member Function Documentation

◆ abortIfMissingDependencies()

InitCtrlService::abortIfMissingDependencies ( Container  $dic)
private

Aborts if another dependency required by the ctrl service is not yet available.

Parameters
Container$dic
Exceptions
ilCtrlExceptionif a necessary dependency is not yet initialized.

Definition at line 77 of file InitCtrlService.php.

77 : void
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 }
ilCtrl exceptions
$dic
Definition: result.php:32

References $dic.

Referenced by init().

+ Here is the caller graph for this function:

◆ init()

InitCtrlService::init ( Container  $dic)

Initializes the ilCtrl service.

This method EXPECTS that $GLOBALS['DIC'] is already initialized with the http services and the refinery factory.

Parameters
Container$dic
Exceptions
ilCtrlExceptionif the initialization fails.

Definition at line 25 of file InitCtrlService.php.

25 : 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 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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.
Class ilCtrlPathFactory.
Class ilCtrlStructure holds the currently read control structure.
Class ilCtrlTokenRepository.
Class ilCtrl provides processing control methods.
$context
Definition: webdav.php:29

References $context, $dic, $GLOBALS, abortIfMissingDependencies(), ilCtrlBaseClassArtifactObjective\ARTIFACT_PATH, ilCtrlSecurityArtifactObjective\ARTIFACT_PATH, and ilCtrlStructureArtifactObjective\ARTIFACT_PATH.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: