ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlSingleClassPath Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilCtrlSingleClassPath:
+ Collaboration diagram for ilCtrlSingleClassPath:

Public Member Functions

 __construct (ilCtrlStructureInterface $structure, ilCtrlContextInterface $context, string $target_class)
 ilCtrlSingleClassPath Constructor More...
 
- Public Member Functions inherited from ilCtrlAbstractPath
 __construct (ilCtrlStructureInterface $structure)
 ilCtrlAbstractPath Constructor More...
 
 getCidPath ()
 
 getCurrentCid ()
 
 getNextCid (string $current_class)
 
 getCidPaths (int $order=SORT_DESC)
 
 getCidArray (int $order=SORT_DESC)
 
 getBaseClass ()
 
 getException ()
 

Private Member Functions

 getCidPathByClass (string $target_class)
 Returns a cid path that reaches from the current context's baseclass to the given class. More...
 

Private Attributes

ilCtrlContextInterface $context
 

Additional Inherited Members

- Data Fields inherited from ilCtrlPathInterface
const CID_PATH_SEPARATOR = ':'
 
- Protected Member Functions inherited from ilCtrlAbstractPath
 getPathToRelatedClassInContext (ilCtrlContextInterface $context, string $target_class)
 Returns the path to a class within the given contexts current path that has a relation to the given target. More...
 
 isClassChildOf (string $child_class, string $parent_class)
 Returns whether the given target class is a child of the other given class. More...
 
 isClassParentOf (string $parent_class, string $child_class)
 Returns whether the given target class is a parent of the other given class. More...
 
 appendCid (string $cid, string $path=null)
 Helper function to add CIDs to a given path. More...
 
- Protected Attributes inherited from ilCtrlAbstractPath
ilCtrlStructureInterface $structure
 
ilCtrlException $exception = null
 
string $cid_path = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilCtrlSingleClassPath

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns

Definition at line 25 of file class.ilCtrlSingleClassPath.php.

Constructor & Destructor Documentation

◆ __construct()

ilCtrlSingleClassPath::__construct ( ilCtrlStructureInterface  $structure,
ilCtrlContextInterface  $context,
string  $target_class 
)

ilCtrlSingleClassPath Constructor

Parameters
ilCtrlStructureInterface$structure
ilCtrlContextInterface$context
string$target_class

Definition at line 39 of file class.ilCtrlSingleClassPath.php.

References $context, ilCtrlAbstractPath\$exception, ILIAS\GlobalScreen\Provider\__construct(), and getCidPathByClass().

40  {
41  parent::__construct($structure);
42 
43  $this->context = $context;
44 
45  try {
46  $this->cid_path = $this->getCidPathByClass($target_class);
47  } catch (ilCtrlException $exception) {
48  $this->exception = $exception;
49  }
50  }
getCidPathByClass(string $target_class)
Returns a cid path that reaches from the current context's baseclass to the given class...
ilCtrlContextInterface $context
ilCtrl exceptions
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getCidPathByClass()

ilCtrlSingleClassPath::getCidPathByClass ( string  $target_class)
private

Returns a cid path that reaches from the current context's baseclass to the given class.

If the given class cannot be reached from the context's baseclass this instance must be given a class array instead.

Parameters
string$target_class
Returns
string
Exceptions
ilCtrlExceptionif the class has no relations or cannot reach the baseclass of this context.

Definition at line 64 of file class.ilCtrlSingleClassPath.php.

References ilCtrlAbstractPath\appendCid(), and ilCtrlAbstractPath\getPathToRelatedClassInContext().

Referenced by __construct().

64  : string
65  {
66  $target_cid = $this->structure->getClassCidByName($target_class);
67 
68  // abort if the target class is unknown.
69  if (null === $target_cid) {
70  throw new ilCtrlException("Class '$target_class' was not found in the control structure, try `composer du` to read artifacts.");
71  }
72 
73  // if the target class is already the current command
74  // class of this context, nothing has to be changed.
75  if ($target_cid === $this->context->getPath()->getCurrentCid()) {
76  return $this->context->getPath()->getCidPath();
77  }
78 
79  // check if the target is related to a class within
80  // the current context's path.
81  $related_class_path = $this->getPathToRelatedClassInContext($this->context, $target_class);
82  if (null !== $related_class_path) {
83  return $this->appendCid($target_cid, $related_class_path);
84  }
85 
86  // fix https://mantis.ilias.de/view.php?id=33094:
87  // prioritise baseclasses less than relationships,
88  // therefore test at last if the target class is a
89  // baseclass.
90  if ($this->structure->isBaseClass($target_class)) {
91  return $target_cid;
92  }
93 
94  throw new ilCtrlException("ilCtrl cannot find a path for '$target_class' that reaches '{$this->context->getBaseClass()}'");
95  }
getPathToRelatedClassInContext(ilCtrlContextInterface $context, string $target_class)
Returns the path to a class within the given contexts current path that has a relation to the given t...
appendCid(string $cid, string $path=null)
Helper function to add CIDs to a given path.
ilCtrl exceptions
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $context

ilCtrlContextInterface ilCtrlSingleClassPath::$context
private

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

Referenced by __construct().


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