ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCtrlAbstractPath Class Reference

Class ilCtrlAbstractPath. More...

+ Inheritance diagram for ilCtrlAbstractPath:
+ Collaboration diagram for ilCtrlAbstractPath:

Public Member Functions

 __construct (ilCtrlStructureInterface $structure)
 ilCtrlAbstractPath Constructor More...
 
 getCidPath ()
 
 getCurrentCid ()
 
 getNextCid (string $current_class)
 
 getCidPaths (int $order=SORT_DESC)
 
 getCidArray (int $order=SORT_DESC)
 
 getBaseClass ()
 
 getException ()
 

Protected Member Functions

 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

ilCtrlStructureInterface $structure
 
ilCtrlException $exception = null
 
string $cid_path = null
 

Additional Inherited Members

- Data Fields inherited from ilCtrlPathInterface
const CID_PATH_SEPARATOR = ':'
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCtrlAbstractPath::__construct ( ilCtrlStructureInterface  $structure)

ilCtrlAbstractPath Constructor

Parameters
ilCtrlStructureInterface$structure

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

References $structure.

49  {
50  $this->structure = $structure;
51  }
ilCtrlStructureInterface $structure

Member Function Documentation

◆ appendCid()

ilCtrlAbstractPath::appendCid ( string  $cid,
?string  $path = null 
)
protected

Helper function to add CIDs to a given path.

Parameters
string$cid
string | null$path
Returns
string

Definition at line 237 of file class.ilCtrlAbstractPath.php.

References $path, and null.

Referenced by ilCtrlArrayClassPath\getCidPathByArray(), ilCtrlSingleClassPath\getCidPathByClass(), and getCidPaths().

237  : string
238  {
239  if (null === $path) {
240  return $cid;
241  }
242 
243  return $path . self::CID_PATH_SEPARATOR . $cid;
244  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getBaseClass()

ilCtrlAbstractPath::getBaseClass ( )

Implements ilCtrlPathInterface.

Definition at line 147 of file class.ilCtrlAbstractPath.php.

References getCidArray(), and null.

147  : ?string
148  {
149  if (null !== $this->cid_path) {
150  $cid_array = $this->getCidArray(SORT_ASC);
151  $class_name = $this->structure->getClassNameByCid($cid_array[0]);
152  if (null !== $class_name && $this->structure->isBaseClass($class_name)) {
153  return $class_name;
154  }
155  }
156 
157  return null;
158  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getCidArray(int $order=SORT_DESC)
+ Here is the call graph for this function:

◆ getCidArray()

ilCtrlAbstractPath::getCidArray ( int  $order = SORT_DESC)

Implements ilCtrlPathInterface.

Definition at line 130 of file class.ilCtrlAbstractPath.php.

References getCidPath(), and null.

Referenced by getBaseClass(), getCidPaths(), getCurrentCid(), and getNextCid().

130  : array
131  {
132  if (null === $this->getCidPath()) {
133  return [];
134  }
135 
136  $cid_array = explode(self::CID_PATH_SEPARATOR, $this->cid_path);
137  if (SORT_DESC === $order) {
138  $cid_array = array_reverse($cid_array);
139  }
140 
141  return $cid_array;
142  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCidPath()

ilCtrlAbstractPath::getCidPath ( )

Implements ilCtrlPathInterface.

Definition at line 56 of file class.ilCtrlAbstractPath.php.

References $cid_path, and null.

Referenced by getCidArray(), getCidPaths(), and getCurrentCid().

56  : ?string
57  {
58  // cannot use empty(), since '0' would be considered
59  // empty and that's an actual cid.
60  if (null !== $this->cid_path && '' !== $this->cid_path) {
61  return $this->cid_path;
62  }
63 
64  return null;
65  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getCidPaths()

ilCtrlAbstractPath::getCidPaths ( int  $order = SORT_DESC)

Implements ilCtrlPathInterface.

Definition at line 102 of file class.ilCtrlAbstractPath.php.

References appendCid(), getCidArray(), getCidPath(), and null.

102  : array
103  {
104  if (null === $this->getCidPath()) {
105  return [];
106  }
107 
108  // cid array must be ascending, because the
109  // paths should always begin at the baseclass.
110  $cid_array = $this->getCidArray(SORT_ASC);
111  $cid_paths = [];
112 
113  foreach ($cid_array as $index => $cid) {
114  $cid_paths[] = (0 !== $index) ?
115  $this->appendCid($cid, $cid_paths[$index - 1]) :
116  $cid
117  ;
118  }
119 
120  if (SORT_DESC === $order) {
121  $cid_paths = array_reverse($cid_paths);
122  }
123 
124  return $cid_paths;
125  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getCidArray(int $order=SORT_DESC)
appendCid(string $cid, ?string $path=null)
Helper function to add CIDs to a given path.
+ Here is the call graph for this function:

◆ getCurrentCid()

ilCtrlAbstractPath::getCurrentCid ( )

Implements ilCtrlPathInterface.

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

References getCidArray(), getCidPath(), and null.

70  : ?string
71  {
72  if (null !== $this->getCidPath()) {
73  // use default order (command- to baseclass) and
74  // retrieve the last command class (index 0).
75  return $this->getCidArray()[0];
76  }
77 
78  return null;
79  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getCidArray(int $order=SORT_DESC)
+ Here is the call graph for this function:

◆ getException()

ilCtrlAbstractPath::getException ( )

Implements ilCtrlPathInterface.

Definition at line 163 of file class.ilCtrlAbstractPath.php.

References $exception.

163  : ?ilCtrlException
164  {
165  return $this->exception;
166  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getNextCid()

ilCtrlAbstractPath::getNextCid ( string  $current_class)

Implements ilCtrlPathInterface.

Definition at line 84 of file class.ilCtrlAbstractPath.php.

References getCidArray(), and null.

84  : ?string
85  {
86  $current_cid = $this->structure->getClassCidByName($current_class);
87  $cid_array = $this->getCidArray(SORT_ASC);
88  $cid_count = count($cid_array);
89 
90  foreach ($cid_array as $index => $cid) {
91  if ($current_cid === $cid && ($index + 1) < $cid_count) {
92  return $cid_array[$index + 1];
93  }
94  }
95 
96  return null;
97  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getCidArray(int $order=SORT_DESC)
+ Here is the call graph for this function:

◆ getPathToRelatedClassInContext()

ilCtrlAbstractPath::getPathToRelatedClassInContext ( ilCtrlContextInterface  $context,
string  $target_class 
)
protected

Returns the path to a class within the given contexts current path that has a relation to the given target.

Parameters
ilCtrlContextInterface$context
string$target_class
Returns
string|null

Definition at line 176 of file class.ilCtrlAbstractPath.php.

References ilCtrlContextInterface\getPath(), isClassChildOf(), and null.

Referenced by ilCtrlArrayClassPath\getCidPathByArray(), and ilCtrlSingleClassPath\getCidPathByClass().

176  : ?string
177  {
178  if (null !== $context->getPath()->getCidPath()) {
179  foreach ($context->getPath()->getCidArray() as $index => $cid) {
180  $current_class = $this->structure->getClassNameByCid($cid);
181  if (null !== $current_class && $this->isClassChildOf($target_class, $current_class)) {
182  $cid_paths = $context->getPath()->getCidPaths();
183 
184  // return the path to the class related to the
185  // target class.
186  return $cid_paths[$index];
187  }
188  }
189  }
190 
191  return null;
192  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getPath()
Returns the path of this context.
isClassChildOf(string $child_class, string $parent_class)
Returns whether the given target class is a child of the other given class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isClassChildOf()

ilCtrlAbstractPath::isClassChildOf ( string  $child_class,
string  $parent_class 
)
protected

Returns whether the given target class is a child of the other given class.

Parameters
string$child_class
string$parent_class
Returns
bool

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

References null.

Referenced by getPathToRelatedClassInContext().

202  : bool
203  {
204  $children = $this->structure->getChildrenByName($parent_class);
205  if (null !== $children) {
206  return in_array(strtolower($child_class), $children, true);
207  }
208 
209  return false;
210  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ isClassParentOf()

ilCtrlAbstractPath::isClassParentOf ( string  $parent_class,
string  $child_class 
)
protected

Returns whether the given target class is a parent of the other given class.

Parameters
string$parent_class
string$child_class
Returns
bool

Definition at line 220 of file class.ilCtrlAbstractPath.php.

References null.

Referenced by ilCtrlArrayClassPath\getCidPathByArray().

220  : bool
221  {
222  $parents = $this->structure->getParentsByName($child_class);
223  if (null !== $parents) {
224  return in_array(strtolower($parent_class), $parents, true);
225  }
226 
227  return false;
228  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

Field Documentation

◆ $cid_path

string ilCtrlAbstractPath::$cid_path = null
protected

◆ $exception

ilCtrlException ilCtrlAbstractPath::$exception = null
protected

◆ $structure

ilCtrlStructureInterface ilCtrlAbstractPath::$structure
protected

Definition at line 31 of file class.ilCtrlAbstractPath.php.

Referenced by __construct().


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