ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 ()
 @inheritDoc More...
 
 getRedirectSource ()
 @inheritDoc More...
 
 getPath ()
 @inheritDoc More...
 
 setCmdMode (string $mode)
 @inheritDoc More...
 
 getCmdMode ()
 @inheritDoc More...
 
 setBaseClass (string $base_class)
 @inheritDoc More...
 
 getBaseClass ()
 @inheritDoc More...
 
 setTargetScript (string $target_script)
 @inheritDoc More...
 
 getTargetScript ()
 @inheritDoc More...
 
 setCmdClass (?string $cmd_class)
 @inheritDoc More...
 
 getCmdClass ()
 @inheritDoc More...
 
 setCmd (?string $cmd)
 @inheritDoc More...
 
 getCmd ()
 @inheritDoc More...
 
 setObjType (string $obj_type)
 @inheritDoc More...
 
 getObjType ()
 @inheritDoc More...
 
 setObjId (int $obj_id)
 @inheritDoc More...
 
 getObjId ()
 @inheritDoc More...
 
 isAsync ()
 Returns whether this context is asynchronous or not. More...
 
 getRedirectSource ()
 Returns where the request of this context was redirected from. More...
 
 getPath ()
 Returns the path of this context. More...
 
 setCmdMode (string $mode)
 Sets the command mode of the current context. More...
 
 getCmdMode ()
 Returns the command mode of the current context. More...
 
 setBaseClass (string $base_class)
 Sets the baseclass of the current context. More...
 
 getBaseClass ()
 Returns the baseclass the current context. More...
 
 setTargetScript (string $target_script)
 Sets the target script of this context (usually ilias.php). More...
 
 getTargetScript ()
 Returns the target script of this context. More...
 
 setCmdClass (?string $cmd_class)
 Sets the current contexts command class. More...
 
 getCmdClass ()
 Returns the command class of this context. More...
 
 setCmd (?string $cmd)
 Sets the command which the current command- or baseclass should perform. More...
 
 getCmd ()
 Returns the command which the current command- or baseclass should perform. More...
 
 setObjType (string $obj_type)
 Sets the object type of the current context. More...
 
 getObjType ()
 Returns the object type of the current context. More...
 
 setObjId (int $obj_id)
 Sets the object id of the current context. More...
 
 getObjId ()
 Returns the object id of the current context. More...
 

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 @noinspection AutoloadingIssuesInspection

Definition at line 31 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 107 of file class.ilCtrlContext.php.

108 {
109 $this->path_factory = $path_factory;
110 $this->path = $path_factory->null();
111 $this->request_wrapper = $request_wrapper;
112 $this->refinery = $refinery;
113
114 $this->adoptRequestParameters();
115 }
RequestWrapper $request_wrapper
adoptRequestParameters()
Adopts context properties from the according ones delivered by the current request.
ilCtrlPathFactory $path_factory

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

+ 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 288 of file class.ilCtrlContext.php.

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

References $base_class, $cmd_class, ilCtrlInterface\CMD_MODE_ASYNC, decodeNamespaceFromUrl(), 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBaseClass()

ilCtrlContext::getBaseClass ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

180 : ?string
181 {
182 return $this->base_class;
183 }

References $base_class.

◆ getCmd()

ilCtrlContext::getCmd ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

241 : ?string
242 {
243 return $this->cmd;
244 }

References $cmd.

◆ getCmdClass()

ilCtrlContext::getCmdClass ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

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

References $base_class.

◆ getCmdMode()

ilCtrlContext::getCmdMode ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

153 : ?string
154 {
155 return $this->cmd_mode;
156 }

References $cmd_mode.

◆ getObjId()

ilCtrlContext::getObjId ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

275 : ?int
276 {
277 return $this->obj_id;
278 }

References $obj_id.

◆ getObjType()

ilCtrlContext::getObjType ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

258 : ?string
259 {
260 return $this->obj_type;
261 }

References $obj_type.

◆ getPath()

ilCtrlContext::getPath ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

137 {
138 return $this->path;
139 }
ilCtrlPathInterface $path
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $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 327 of file class.ilCtrlContext.php.

327 : ?string
328 {
329 if ($this->request_wrapper->has($parameter_name)) {
330 return $this->request_wrapper->retrieve(
331 $parameter_name,
332 $this->refinery->to()->string()
333 );
334 }
335
336 return null;
337 }

References ILIAS\Repository\refinery().

Referenced by adoptRequestParameters().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRedirectSource()

ilCtrlContext::getRedirectSource ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

128 : ?string
129 {
130 return $this->redirect;
131 }

References $redirect.

◆ getTargetScript()

ilCtrlContext::getTargetScript ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

197 : string
198 {
200 }

References $target_script.

◆ isAsync()

ilCtrlContext::isAsync ( )

@inheritDoc

Implements ilCtrlContextInterface.

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

120 : bool
121 {
122 return $this->is_async;
123 }

References $is_async.

◆ setBaseClass()

ilCtrlContext::setBaseClass ( string  $base_class)

@inheritDoc

Implements ilCtrlContextInterface.

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

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

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

Referenced by adoptRequestParameters().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCmd()

ilCtrlContext::setCmd ( ?string  $cmd)

@inheritDoc

Implements ilCtrlContextInterface.

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

232 {
233 $this->cmd = $cmd;
234
235 return $this;
236 }

References $cmd.

◆ setCmdClass()

ilCtrlContext::setCmdClass ( ?string  $cmd_class)

@inheritDoc

Implements ilCtrlContextInterface.

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

206 {
207 $path = $this->path_factory->find($this, $cmd_class);
208
209 // only set command class if it's a valid target.
210 if (null !== $path->getCidPath()) {
211 $this->cmd_class = $cmd_class;
212 $this->path = $path;
213 }
214
215 return $this;
216 }

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

Referenced by adoptRequestParameters().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCmdMode()

ilCtrlContext::setCmdMode ( string  $mode)

@inheritDoc

Implements ilCtrlContextInterface.

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

145 {
146 $this->cmd_mode = $mode;
147 return $this;
148 }

◆ setObjId()

ilCtrlContext::setObjId ( int  $obj_id)

@inheritDoc

Implements ilCtrlContextInterface.

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

267 {
268 $this->obj_id = $obj_id;
269 return $this;
270 }

References $obj_id.

◆ setObjType()

ilCtrlContext::setObjType ( string  $obj_type)

@inheritDoc

Implements ilCtrlContextInterface.

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

250 {
251 $this->obj_type = $obj_type;
252 return $this;
253 }

References $obj_type.

◆ setTargetScript()

ilCtrlContext::setTargetScript ( string  $target_script)

@inheritDoc

Implements ilCtrlContextInterface.

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

189 {
190 $this->target_script = $target_script;
191 return $this;
192 }

References $target_script.

Field Documentation

◆ $base_class

string ilCtrlContext::$base_class = null
protected

◆ $cmd

string ilCtrlContext::$cmd = null
protected

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

Referenced by getCmd(), and setCmd().

◆ $cmd_class

string ilCtrlContext::$cmd_class = null
protected

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

Referenced by adoptRequestParameters(), and setCmdClass().

◆ $cmd_mode

string ilCtrlContext::$cmd_mode = null
protected

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

Referenced by getCmdMode().

◆ $is_async

bool ilCtrlContext::$is_async = false
protected

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

Referenced by isAsync().

◆ $obj_id

int ilCtrlContext::$obj_id = null
protected

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

Referenced by getObjId(), and setObjId().

◆ $obj_type

string ilCtrlContext::$obj_type = null
protected

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

Referenced by getObjType(), and setObjType().

◆ $path

ilCtrlPathInterface ilCtrlContext::$path
protected

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

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

◆ $path_factory

ilCtrlPathFactory ilCtrlContext::$path_factory
protected

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

Referenced by __construct().

◆ $redirect

string ilCtrlContext::$redirect = null
protected

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

Referenced by getRedirectSource().

◆ $refinery

Refinery ilCtrlContext::$refinery
protected

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

Referenced by __construct().

◆ $request_wrapper

RequestWrapper ilCtrlContext::$request_wrapper
protected

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

Referenced by __construct().

◆ $target_script

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

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

Referenced by getTargetScript(), and setTargetScript().


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