19 declare(strict_types=1);
60 if (
null !== $this->cid_path &&
'' !== $this->cid_path) {
84 public function getNextCid(
string $current_class): ?string
86 $current_cid = $this->structure->getClassCidByName($current_class);
88 $cid_count = count($cid_array);
90 foreach ($cid_array as $index => $cid) {
91 if ($current_cid === $cid && ($index + 1) < $cid_count) {
92 return $cid_array[$index + 1];
113 foreach ($cid_array as $index => $cid) {
114 $cid_paths[] = (0 !== $index) ?
115 $this->
appendCid($cid, $cid_paths[$index - 1]) :
120 if (SORT_DESC === $order) {
121 $cid_paths = array_reverse($cid_paths);
136 $cid_array = explode(self::CID_PATH_SEPARATOR, $this->cid_path);
137 if (SORT_DESC === $order) {
138 $cid_array = array_reverse($cid_array);
149 if (
null !== $this->cid_path) {
151 $class_name = $this->structure->getClassNameByCid($cid_array[0]);
152 if (
null !== $class_name && $this->structure->isBaseClass($class_name)) {
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();
186 return $cid_paths[$index];
202 protected function isClassChildOf(
string $child_class,
string $parent_class): bool
204 $children = $this->structure->getChildrenByName($parent_class);
205 if (
null !== $children) {
206 return in_array(strtolower($child_class), $children,
true);
222 $parents = $this->structure->getParentsByName($child_class);
223 if (
null !== $parents) {
224 return in_array(strtolower($parent_class), $parents,
true);
243 return $path . self::CID_PATH_SEPARATOR . $cid;
getCidPaths(int $order=SORT_DESC)
ilCtrlException $exception
getNextCid(string $current_class)
Class ilCtrlAbstractPath.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isClassParentOf(string $parent_class, string $child_class)
Returns whether the given target class is a parent of the other given class.
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...
getPath()
Returns the path of this context.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isClassChildOf(string $child_class, string $parent_class)
Returns whether the given target class is a child of the other given class.
getCidArray(int $order=SORT_DESC)
appendCid(string $cid, ?string $path=null)
Helper function to add CIDs to a given path.
__construct(ilCtrlStructureInterface $structure)
ilCtrlAbstractPath Constructor
ilCtrlStructureInterface $structure
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...