3 declare(strict_types=1);
46 if (null !== $this->cid_path &&
'' !== $this->cid_path) {
70 public function getNextCid(
string $current_class): ?string
72 $current_cid = $this->structure->getClassCidByName($current_class);
74 $cid_count = count($cid_array);
76 foreach ($cid_array as
$index => $cid) {
77 if ($current_cid === $cid && (
$index + 1) < $cid_count) {
78 return $cid_array[
$index + 1];
99 foreach ($cid_array as
$index => $cid) {
100 $cid_paths[] = (0 !==
$index) ?
106 if (SORT_DESC === $order) {
107 $cid_paths = array_reverse($cid_paths);
122 $cid_array = explode(self::CID_PATH_SEPARATOR, $this->cid_path);
123 if (SORT_DESC === $order) {
124 $cid_array = array_reverse($cid_array);
135 if (null !== $this->cid_path) {
137 $class_name = $this->structure->getClassNameByCid($cid_array[0]);
138 if (null !== $class_name && $this->structure->isBaseClass($class_name)) {
164 if (null !== $context->
getPath()->getCidPath()) {
165 foreach ($context->
getPath()->getCidArray() as
$index => $cid) {
166 $current_class = $this->structure->getClassNameByCid($cid);
167 if (null !== $current_class && $this->
isClassChildOf($target_class, $current_class)) {
168 $cid_paths = $context->
getPath()->getCidPaths();
172 return $cid_paths[
$index];
188 protected function isClassChildOf(
string $child_class,
string $parent_class): bool
190 $children = $this->structure->getChildrenByName($parent_class);
191 if (null !== $children) {
192 return in_array(strtolower($child_class), $children,
true);
208 $parents = $this->structure->getParentsByName($child_class);
209 if (null !== $parents) {
210 return in_array(strtolower($parent_class), $parents,
true);
225 if (null ===
$path) {
229 return $path . self::CID_PATH_SEPARATOR . $cid;
getCidPaths(int $order=SORT_DESC)
ilCtrlException $exception
getNextCid(string $current_class)
Class ilCtrlAbstractPath.
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...
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.
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.
getCidArray(int $order=SORT_DESC)
__construct(ilCtrlStructureInterface $structure)
ilCtrlAbstractPath Constructor
ilCtrlStructureInterface $structure
Interface ilCtrlPathInterface is responsible for holding and manipulating a valid ilCtrl class-path (...