ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilCtrlExistingPath.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6
13{
21 {
23
24 $this->cid_path = $cid_path;
25 $this->ensureValidCidPath();
26 }
27
32 protected function ensureValidCidPath(): void
33 {
34 $cid_array = $this->getCidArray(SORT_ASC);
35 $cid_count = count($cid_array);
36 if ($cid_count <= 1) {
37 return;
38 }
39 for ($current = 0, $max = ($cid_count - 1); $current < $max; $current++) {
40 $parent_cid = $cid_array[$current];
41 $child_cid = $cid_array[$current + 1];
42 $child_class = $this->structure->getClassNameByCid($child_cid);
43 $allowed_children = $this->structure->getChildrenByCid($parent_cid);
44 if (null === $child_class || !in_array($child_class, $allowed_children, true)) {
45 throw new RuntimeException('ilCtrl: invalid ' . ilCtrlInterface::PARAM_CID_PATH . ' parameter requested.');
46 }
47 }
48 }
49}
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc