ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilCtrlExistingPath.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
35 {
37
38 $this->cid_path = $cid_path;
39 $this->ensureValidCidPath();
40 }
41
46 protected function ensureValidCidPath(): void
47 {
48 $cid_array = $this->getCidArray(SORT_ASC);
49 $cid_count = count($cid_array);
50 if ($cid_count <= 1) {
51 return;
52 }
53 for ($current = 0, $max = ($cid_count - 1); $current < $max; $current++) {
54 $parent_cid = $cid_array[$current];
55 $child_cid = $cid_array[$current + 1];
56 $child_class = $this->structure->getClassNameByCid($child_cid);
57 $allowed_children = $this->structure->getChildrenByCid($parent_cid) ?? [];
58 if (null === $child_class || !in_array($child_class, $allowed_children, true)) {
59 throw new RuntimeException('ilCtrl: invalid ' . ilCtrlInterface::PARAM_CID_PATH . ' parameter requested.');
60 }
61 }
62 }
63}
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