ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCtrlSingleClassPath Class Reference

Class ilCtrlSingleClassPath. 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

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 40 of file class.ilCtrlSingleClassPath.php.

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

41  {
42  parent::__construct($structure);
43 
44  $this->context = $context;
45 
46  try {
47  $this->cid_path = $this->getCidPathByClass($target_class);
48  } catch (ilCtrlException $exception) {
49  $this->exception = $exception;
50  }
51  }
getCidPathByClass(string $target_class)
Returns a cid path that reaches from the current context's baseclass to the given class...
ilCtrlContextInterface $context
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__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 65 of file class.ilCtrlSingleClassPath.php.

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

Referenced by __construct().

65  : string
66  {
67  $target_cid = $this->structure->getClassCidByName($target_class);
68 
69  // abort if the target class is unknown.
70  if (null === $target_cid) {
71  throw new ilCtrlException("Class '$target_class' was not found in the control structure, try `composer du` to read artifacts.");
72  }
73 
74  // if the target class is already the current command
75  // class of this context, nothing has to be changed.
76  if ($target_cid === $this->context->getPath()->getCurrentCid()) {
77  return $this->context->getPath()->getCidPath();
78  }
79 
80  // check if the target is related to a class within
81  // the current context's path.
82  $related_class_path = $this->getPathToRelatedClassInContext($this->context, $target_class);
83  if (null !== $related_class_path) {
84  return $this->appendCid($target_cid, $related_class_path);
85  }
86 
87  // fix https://mantis.ilias.de/view.php?id=33094:
88  // prioritise baseclasses less than relationships,
89  // therefore test at last if the target class is a
90  // baseclass.
91  if ($this->structure->isBaseClass($target_class)) {
92  return $target_cid;
93  }
94 
95  throw new ilCtrlException("ilCtrl cannot find a path for '$target_class' that reaches '{$this->context->getBaseClass()}'");
96  }
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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
appendCid(string $cid, ?string $path=null)
Helper function to add CIDs to a given path.
+ 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 31 of file class.ilCtrlSingleClassPath.php.

Referenced by __construct().


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