ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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.

Referenced by init().

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  }
ilCtrl exceptions
+ 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.

References $context, $GLOBALS, abortIfMissingDependencies(), ilCtrlStructureArtifactObjective\ARTIFACT_PATH, ilCtrlBaseClassArtifactObjective\ARTIFACT_PATH, ilCtrlSecurityArtifactObjective\ARTIFACT_PATH, ILIAS\DI\Container\http(), and ILIAS\DI\Container\refinery().

40  : void
41  {
42  $this->abortIfMissingDependencies($dic);
43  $ilias_path = dirname(__FILE__, 5) . '/';
44 
45  try {
46  $ctrl_structure = new ilCtrlStructure(
50  );
51  } catch (Throwable $t) {
52  throw new ilCtrlException(self::class . " could not require artifacts, try `composer du` first.");
53  }
54 
55  $token_repository = new ilCtrlTokenRepository();
56  $path_factory = new ilCtrlPathFactory($ctrl_structure);
57  $context = new ilCtrlContext(
58  $path_factory,
59  $dic->http()->wrapper()->query(),
60  $dic->refinery()
61  );
62 
63  // create global instance of ilCtrl
64  $GLOBALS['ilCtrl'] = new ilCtrl(
65  $ctrl_structure,
66  $token_repository,
67  $path_factory,
68  $context,
69  $dic["http.response_sender_strategy"],
70  $dic->http()->request(),
71  $dic->http()->wrapper()->post(),
72  $dic->http()->wrapper()->query(),
73  $dic->refinery(),
74  $dic["component.factory"],
75  new ilCtrlSubject(),
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  }
$context
Definition: webdav.php:31
Class ilCtrlPathFactory.
Class ilCtrlContext is responsible for holding the current context information.
Class ilCtrlStructure holds the currently read control structure.
$GLOBALS["DIC"]
Definition: wac.php:31
Class ilCtrlTokenRepository.
abortIfMissingDependencies(Container $dic)
Aborts if another dependency required by the ctrl service is not yet available.
ilCtrl exceptions
+ Here is the call graph for this function:

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