ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 31 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 93 of file InitCtrlService.php.

93 : void
94 {
95 if (!$dic->offsetExists('http')) {
96 throw new ilCtrlException("Cannot initialize ilCtrl if HTTP Services are not yet available.");
97 }
98
99 if (!$dic->offsetExists('refinery')) {
100 throw new ilCtrlException("Cannot initialize ilCtrl if Refinery Factory is not yet available.");
101 }
102
103 // if (!$dic->offsetExists('ilDB')) {
104 // throw new ilCtrlException("Cannot initialize ilCtrl if Database is not yet available.");
105 // }
106 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References XapiProxy\$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 40 of file InitCtrlService.php.

40 : void
41 {
42 $this->abortIfMissingDependencies($dic);
43
44 try {
45 $ctrl_structure = new ilCtrlStructure(
49 );
50 } catch (Throwable $t) {
51 throw new ilCtrlException(self::class . " could not require artifacts, try `composer du` first.");
52 }
53
54 $token_repository = new ilCtrlTokenRepository();
55 $path_factory = new ilCtrlPathFactory($ctrl_structure);
56 $context = new ilCtrlContext(
57 $path_factory,
58 $dic->http()->wrapper()->query(),
59 $dic->refinery()
60 );
61
62 // create global instance of ilCtrl
63 $GLOBALS['ilCtrl'] = new ilCtrl(
64 $ctrl_structure,
65 $token_repository,
66 $path_factory,
67 $context,
68 $dic->http()->sender(),
69 $dic->http()->request(),
70 $dic->http()->wrapper()->post(),
71 $dic->http()->wrapper()->query(),
72 $dic->refinery(),
73 $dic["component.factory"],
74 new ilCtrlSubject(),
76 $dic->http()->messages(),
77 );
78
79 // add helper function to DI container that
80 // returns the global instance.
81 $dic['ilCtrl'] = static function () {
82 return $GLOBALS['ilCtrl'];
83 };
84 }
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.
$GLOBALS["DIC"]
Definition: wac.php:66

References XapiProxy\$dic, $GLOBALS, abortIfMissingDependencies(), and ILIAS\Setup\Artifact\BuildArtifactObjective\PATH().

+ Here is the call graph for this function:

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