ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlContext Class Reference

Class ilCtrlContext is responsible for holding the current context information. More...

+ Inheritance diagram for ilCtrlContext:
+ Collaboration diagram for ilCtrlContext:

Public Member Functions

 __construct (ilCtrlPathFactory $path_factory, RequestWrapper $request_wrapper, Refinery $refinery)
 ilCtrlContext Constructor More...
 
 isAsync ()
 
 getRedirectSource ()
 
 getPath ()
 
 setCmdMode (string $mode)
 
 getCmdMode ()
 
 setBaseClass (string $base_class)
 
 getBaseClass ()
 
 setTargetScript (string $target_script)
 
 getTargetScript ()
 
 setCmdClass (?string $cmd_class)
 
 getCmdClass ()
 
 setCmd (?string $cmd)
 
 getCmd ()
 
 setObjType (string $obj_type)
 
 getObjType ()
 
 setObjId (int $obj_id)
 
 getObjId ()
 

Protected Member Functions

 adoptRequestParameters ()
 Adopts context properties from the according ones delivered by the current request. More...
 
 getQueryParam (string $parameter_name)
 Helper function to retrieve request parameter values by name. More...
 

Protected Attributes

ilCtrlPathFactory $path_factory
 
RequestWrapper $request_wrapper
 
Refinery $refinery
 
ilCtrlPathInterface $path
 
bool $is_async = false
 
string $target_script = 'ilias.php'
 
string $cmd_mode = null
 
string $redirect = null
 
string $base_class = null
 
string $cmd_class = null
 
string $cmd = null
 
string $obj_type = null
 
int $obj_id = null
 

Detailed Description

Class ilCtrlContext is responsible for holding the current context information.

Author
Thibeau Fuhrer thf@s.nosp@m.tude.nosp@m.r-rai.nosp@m.mann.nosp@m..ch AutoloadingIssuesInspection

Definition at line 30 of file class.ilCtrlContext.php.

Constructor & Destructor Documentation

◆ __construct()

ilCtrlContext::__construct ( ilCtrlPathFactory  $path_factory,
RequestWrapper  $request_wrapper,
Refinery  $refinery 
)

ilCtrlContext Constructor

Parameters
ilCtrlPathFactory$path_factory
RequestWrapper$request_wrapper
Refinery$refinery

Definition at line 104 of file class.ilCtrlContext.php.

References $path_factory, $refinery, $request_wrapper, adoptRequestParameters(), ilCtrlPathFactory\null(), and ILIAS\Repository\refinery().

105  {
106  $this->path_factory = $path_factory;
107  $this->path = $path_factory->null();
108  $this->request_wrapper = $request_wrapper;
109  $this->refinery = $refinery;
110 
111  $this->adoptRequestParameters();
112  }
RequestWrapper $request_wrapper
adoptRequestParameters()
Adopts context properties from the according ones delivered by the current request.
ilCtrlPathFactory $path_factory
+ Here is the call graph for this function:

Member Function Documentation

◆ adoptRequestParameters()

ilCtrlContext::adoptRequestParameters ( )
protected

Adopts context properties from the according ones delivered by the current request.

Note that this method should only be called when initializing ilCtrl, as methods may override delivered values on purpose later on.

Definition at line 285 of file class.ilCtrlContext.php.

References ilCtrlInterface\CMD_MODE_ASYNC, getQueryParam(), ilCtrlInterface\PARAM_BASE_CLASS, ilCtrlInterface\PARAM_CID_PATH, ilCtrlInterface\PARAM_CMD, ilCtrlInterface\PARAM_CMD_CLASS, ilCtrlInterface\PARAM_CMD_MODE, ilCtrlInterface\PARAM_REDIRECT, setBaseClass(), and setCmdClass().

Referenced by __construct().

285  : void
286  {
287  $this->redirect = $this->getQueryParam(ilCtrlInterface::PARAM_REDIRECT);
288  $this->cmd_mode = $this->getQueryParam(ilCtrlInterface::PARAM_CMD_MODE);
289  $this->cmd = $this->getQueryParam(ilCtrlInterface::PARAM_CMD);
290 
291  // the context is considered asynchronous if
292  // the command mode is 'async'.
293  if (ilCtrlInterface::CMD_MODE_ASYNC === $this->cmd_mode) {
294  $this->is_async = true;
295  }
296 
297  // if an existing path is provided use it by default.
298  $existing_path = $this->getQueryParam(ilCtrlInterface::PARAM_CID_PATH);
299  if (null !== $existing_path) {
300  $this->path = $this->path_factory->existing($existing_path);
301  }
302 
303  // set the provided baseclass, which might override the
304  // previously set existing path.
306  if (null !== $base_class) {
307  $this->setBaseClass($base_class);
308  }
309 
310  // set or append the provided command class, which might
311  // override the previously set path again.
313  if (null !== $cmd_class) {
314  $this->setCmdClass($cmd_class);
315  }
316  }
setBaseClass(string $base_class)
getQueryParam(string $parameter_name)
Helper function to retrieve request parameter values by name.
setCmdClass(?string $cmd_class)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBaseClass()

ilCtrlContext::getBaseClass ( )

Implements ilCtrlContextInterface.

Definition at line 177 of file class.ilCtrlContext.php.

References $base_class.

177  : ?string
178  {
179  return $this->base_class;
180  }

◆ getCmd()

ilCtrlContext::getCmd ( )

Implements ilCtrlContextInterface.

Definition at line 238 of file class.ilCtrlContext.php.

References $cmd.

238  : ?string
239  {
240  return $this->cmd;
241  }

◆ getCmdClass()

ilCtrlContext::getCmdClass ( )

Implements ilCtrlContextInterface.

Definition at line 218 of file class.ilCtrlContext.php.

References $base_class.

218  : ?string
219  {
220  // if no cmd_class is set yet, the baseclass
221  // value can be returned.
222  return $this->cmd_class ?? $this->base_class;
223  }

◆ getCmdMode()

ilCtrlContext::getCmdMode ( )

Implements ilCtrlContextInterface.

Definition at line 150 of file class.ilCtrlContext.php.

References $cmd_mode.

150  : ?string
151  {
152  return $this->cmd_mode;
153  }

◆ getObjId()

ilCtrlContext::getObjId ( )

Implements ilCtrlContextInterface.

Definition at line 272 of file class.ilCtrlContext.php.

References $obj_id.

272  : ?int
273  {
274  return $this->obj_id;
275  }

◆ getObjType()

ilCtrlContext::getObjType ( )

Implements ilCtrlContextInterface.

Definition at line 255 of file class.ilCtrlContext.php.

References $obj_type.

255  : ?string
256  {
257  return $this->obj_type;
258  }

◆ getPath()

ilCtrlContext::getPath ( )

Implements ilCtrlContextInterface.

Definition at line 133 of file class.ilCtrlContext.php.

References $path.

134  {
135  return $this->path;
136  }
ilCtrlPathInterface $path
Interface ilCtrlPathInterface is responsible for holding and manipulating a valid ilCtrl class-path (...

◆ getQueryParam()

ilCtrlContext::getQueryParam ( string  $parameter_name)
protected

Helper function to retrieve request parameter values by name.

Parameters
string$parameter_name
Returns
string|null

Definition at line 324 of file class.ilCtrlContext.php.

References ILIAS\Repository\refinery().

Referenced by adoptRequestParameters().

324  : ?string
325  {
326  if ($this->request_wrapper->has($parameter_name)) {
327  return $this->request_wrapper->retrieve(
328  $parameter_name,
329  $this->refinery->to()->string()
330  );
331  }
332 
333  return null;
334  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRedirectSource()

ilCtrlContext::getRedirectSource ( )

Implements ilCtrlContextInterface.

Definition at line 125 of file class.ilCtrlContext.php.

References $redirect.

125  : ?string
126  {
127  return $this->redirect;
128  }

◆ getTargetScript()

ilCtrlContext::getTargetScript ( )

Implements ilCtrlContextInterface.

Definition at line 194 of file class.ilCtrlContext.php.

References $target_script.

194  : string
195  {
196  return $this->target_script;
197  }

◆ isAsync()

ilCtrlContext::isAsync ( )

Implements ilCtrlContextInterface.

Definition at line 117 of file class.ilCtrlContext.php.

References $is_async.

117  : bool
118  {
119  return $this->is_async;
120  }

◆ setBaseClass()

ilCtrlContext::setBaseClass ( string  $base_class)

Implements ilCtrlContextInterface.

Definition at line 158 of file class.ilCtrlContext.php.

References $base_class, $path, and ilCtrlPathInterface\getCidPath().

Referenced by adoptRequestParameters().

159  {
160  $path = $this->path_factory->find($this, $base_class);
161 
162  // only set baseclass if it's a valid target.
163  if (null !== $path->getCidPath()) {
164  $this->base_class = $base_class;
165  // only update the path if the current one is null.
166  if (null === $this->path->getCidPath()) {
167  $this->path = $path;
168  }
169  }
170 
171  return $this;
172  }
getCidPath()
Returns the CID path for the target class of the current instance.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilCtrlPathInterface $path
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCmd()

ilCtrlContext::setCmd ( ?string  $cmd)

Implements ilCtrlContextInterface.

Definition at line 228 of file class.ilCtrlContext.php.

References $cmd.

229  {
230  $this->cmd = $cmd;
231 
232  return $this;
233  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setCmdClass()

ilCtrlContext::setCmdClass ( ?string  $cmd_class)

Implements ilCtrlContextInterface.

Definition at line 202 of file class.ilCtrlContext.php.

References $cmd_class, $path, and ilCtrlPathInterface\getCidPath().

Referenced by adoptRequestParameters().

203  {
204  $path = $this->path_factory->find($this, $cmd_class);
205 
206  // only set command class if it's a valid target.
207  if (null !== $path->getCidPath()) {
208  $this->cmd_class = $cmd_class;
209  $this->path = $path;
210  }
211 
212  return $this;
213  }
getCidPath()
Returns the CID path for the target class of the current instance.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilCtrlPathInterface $path
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCmdMode()

ilCtrlContext::setCmdMode ( string  $mode)

Implements ilCtrlContextInterface.

Definition at line 141 of file class.ilCtrlContext.php.

142  {
143  $this->cmd_mode = $mode;
144  return $this;
145  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setObjId()

ilCtrlContext::setObjId ( int  $obj_id)

Implements ilCtrlContextInterface.

Definition at line 263 of file class.ilCtrlContext.php.

References $obj_id.

264  {
265  $this->obj_id = $obj_id;
266  return $this;
267  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setObjType()

ilCtrlContext::setObjType ( string  $obj_type)

Implements ilCtrlContextInterface.

Definition at line 246 of file class.ilCtrlContext.php.

References $obj_type.

247  {
248  $this->obj_type = $obj_type;
249  return $this;
250  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setTargetScript()

ilCtrlContext::setTargetScript ( string  $target_script)

Implements ilCtrlContextInterface.

Definition at line 185 of file class.ilCtrlContext.php.

References $target_script.

186  {
187  $this->target_script = $target_script;
188  return $this;
189  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Field Documentation

◆ $base_class

string ilCtrlContext::$base_class = null
protected

Definition at line 75 of file class.ilCtrlContext.php.

Referenced by getBaseClass(), getCmdClass(), and setBaseClass().

◆ $cmd

string ilCtrlContext::$cmd = null
protected

Definition at line 85 of file class.ilCtrlContext.php.

Referenced by getCmd(), and setCmd().

◆ $cmd_class

string ilCtrlContext::$cmd_class = null
protected

Definition at line 80 of file class.ilCtrlContext.php.

Referenced by setCmdClass().

◆ $cmd_mode

string ilCtrlContext::$cmd_mode = null
protected

Definition at line 65 of file class.ilCtrlContext.php.

Referenced by getCmdMode().

◆ $is_async

bool ilCtrlContext::$is_async = false
protected

Definition at line 55 of file class.ilCtrlContext.php.

Referenced by isAsync().

◆ $obj_id

int ilCtrlContext::$obj_id = null
protected

Definition at line 95 of file class.ilCtrlContext.php.

Referenced by getObjId(), and setObjId().

◆ $obj_type

string ilCtrlContext::$obj_type = null
protected

Definition at line 90 of file class.ilCtrlContext.php.

Referenced by getObjType(), and setObjType().

◆ $path

ilCtrlPathInterface ilCtrlContext::$path
protected

Definition at line 50 of file class.ilCtrlContext.php.

Referenced by getPath(), setBaseClass(), and setCmdClass().

◆ $path_factory

ilCtrlPathFactory ilCtrlContext::$path_factory
protected

Definition at line 35 of file class.ilCtrlContext.php.

Referenced by __construct().

◆ $redirect

string ilCtrlContext::$redirect = null
protected

Definition at line 70 of file class.ilCtrlContext.php.

Referenced by getRedirectSource().

◆ $refinery

Refinery ilCtrlContext::$refinery
protected

Definition at line 45 of file class.ilCtrlContext.php.

Referenced by __construct().

◆ $request_wrapper

RequestWrapper ilCtrlContext::$request_wrapper
protected

Definition at line 40 of file class.ilCtrlContext.php.

Referenced by __construct().

◆ $target_script

string ilCtrlContext::$target_script = 'ilias.php'
protected

Definition at line 60 of file class.ilCtrlContext.php.

Referenced by getTargetScript(), and setTargetScript().


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