ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilCtrlExistingPath.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29{
37 {
39
40 $this->cid_path = $cid_path;
41 $this->ensureValidCidPath();
42 }
43
48 protected function ensureValidCidPath(): void
49 {
50 $cid_array = $this->getCidArray(SORT_ASC);
51 $cid_count = count($cid_array);
52 if ($cid_count <= 1) {
53 return;
54 }
55 for ($current = 0, $max = ($cid_count - 1); $current < $max; $current++) {
56 $parent_cid = $cid_array[$current];
57 $child_cid = $cid_array[$current + 1];
58 $child_class = $this->structure->getClassNameByCid($child_cid);
59 $allowed_children = $this->structure->getChildrenByCid($parent_cid) ?? [];
60 if (null === $child_class || !in_array($child_class, $allowed_children, true)) {
61 throw new ilCtrlPathException('ilCtrl: invalid ' . ilCtrlInterface::PARAM_CID_PATH . ' parameter requested.');
62 }
63 }
64 }
65}
Thrown when ilCtrl encounters an invalid or unresolvable CID path during request dispatching.
Class ilCtrlAbstractPath.
ilCtrlStructureInterface $structure
getCidArray(int $order=SORT_DESC)
@inheritDoc
Class ilCtrlExistingPath.
ensureValidCidPath()
Ensures each consecutive pair of CIDs must have a valid parent–child relationship.
__construct(ilCtrlStructureInterface $structure, string $cid_path)
ilCtrlExistingPath Constructor
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc