ILIAS  release_8 Revision v8.24
ilCtrlAbstractPath Class Reference

Class ilCtrlAbstractPath. More...

+ Inheritance diagram for ilCtrlAbstractPath:
+ Collaboration diagram for ilCtrlAbstractPath:

Public Member Functions

 __construct (ilCtrlStructureInterface $structure)
 ilCtrlAbstractPath Constructor More...
 
 getCidPath ()
 @inheritDoc More...
 
 getCurrentCid ()
 @inheritDoc More...
 
 getNextCid (string $current_class)
 @inheritDoc More...
 
 getCidPaths (int $order=SORT_DESC)
 @inheritDoc More...
 
 getCidArray (int $order=SORT_DESC)
 @inheritDoc More...
 
 getBaseClass ()
 @inheritDoc More...
 
 getException ()
 @inheritDoc More...
 
 getCidPath ()
 Returns the CID path for the target class of the current instance. More...
 
 getCurrentCid ()
 Returns the CID that must currently be processed. More...
 
 getNextCid (string $current_class)
 Returns the next CID that must be processed. More...
 
 getCidPaths (int $order=SORT_DESC)
 Returns all individual paths for each cid position for the given direction. More...
 
 getCidArray (int $order=SORT_DESC)
 Returns all cid's from the current path in the provided directory/order. More...
 
 getBaseClass ()
 Returns the baseclass of the current cid path. More...
 
 getException ()
 Returns the exception produced during the path-finding- process. More...
 

Protected Member Functions

 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 target. More...
 
 isClassChildOf (string $child_class, string $parent_class)
 Returns whether the given target class is a child of the other given class. More...
 
 isClassParentOf (string $parent_class, string $child_class)
 Returns whether the given target class is a parent of the other given class. More...
 
 appendCid (string $cid, string $path=null)
 Helper function to add CIDs to a given path. More...
 

Protected Attributes

ilCtrlStructureInterface $structure
 
ilCtrlException $exception = null
 
string $cid_path = null
 

Additional Inherited Members

- Data Fields inherited from ilCtrlPathInterface
const CID_PATH_SEPARATOR = ':'
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCtrlAbstractPath::__construct ( ilCtrlStructureInterface  $structure)

ilCtrlAbstractPath Constructor

Parameters
ilCtrlStructureInterface$structure

Definition at line 34 of file class.ilCtrlAbstractPath.php.

35 {
36 $this->structure = $structure;
37 }
ilCtrlStructureInterface $structure

References $structure.

Member Function Documentation

◆ appendCid()

ilCtrlAbstractPath::appendCid ( string  $cid,
string  $path = null 
)
protected

Helper function to add CIDs to a given path.

Parameters
string$cid
string | null$path
Returns
string

Definition at line 223 of file class.ilCtrlAbstractPath.php.

223 : string
224 {
225 if (null === $path) {
226 return $cid;
227 }
228
229 return $path . self::CID_PATH_SEPARATOR . $cid;
230 }
$path
Definition: ltiservices.php:32

References $path.

Referenced by ilCtrlArrayClassPath\getCidPathByArray(), ilCtrlSingleClassPath\getCidPathByClass(), and getCidPaths().

+ Here is the caller graph for this function:

◆ getBaseClass()

ilCtrlAbstractPath::getBaseClass ( )

@inheritDoc

Implements ilCtrlPathInterface.

Definition at line 133 of file class.ilCtrlAbstractPath.php.

133 : ?string
134 {
135 if (null !== $this->cid_path) {
136 $cid_array = $this->getCidArray(SORT_ASC);
137 $class_name = $this->structure->getClassNameByCid($cid_array[0]);
138 if (null !== $class_name && $this->structure->isBaseClass($class_name)) {
139 return $class_name;
140 }
141 }
142
143 return null;
144 }
getCidArray(int $order=SORT_DESC)
@inheritDoc

References getCidArray().

+ Here is the call graph for this function:

◆ getCidArray()

ilCtrlAbstractPath::getCidArray ( int  $order = SORT_DESC)

@inheritDoc

Implements ilCtrlPathInterface.

Definition at line 116 of file class.ilCtrlAbstractPath.php.

116 : array
117 {
118 if (null === $this->getCidPath()) {
119 return [];
120 }
121
122 $cid_array = explode(self::CID_PATH_SEPARATOR, $this->cid_path);
123 if (SORT_DESC === $order) {
124 $cid_array = array_reverse($cid_array);
125 }
126
127 return $cid_array;
128 }

References getCidPath().

Referenced by getBaseClass(), getCidPaths(), getCurrentCid(), and getNextCid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCidPath()

ilCtrlAbstractPath::getCidPath ( )

@inheritDoc

Implements ilCtrlPathInterface.

Definition at line 42 of file class.ilCtrlAbstractPath.php.

42 : ?string
43 {
44 // cannot use empty(), since '0' would be considered
45 // empty and that's an actual cid.
46 if (null !== $this->cid_path && '' !== $this->cid_path) {
47 return $this->cid_path;
48 }
49
50 return null;
51 }

References $cid_path.

Referenced by getCidArray(), getCidPaths(), and getCurrentCid().

+ Here is the caller graph for this function:

◆ getCidPaths()

ilCtrlAbstractPath::getCidPaths ( int  $order = SORT_DESC)

@inheritDoc

Implements ilCtrlPathInterface.

Definition at line 88 of file class.ilCtrlAbstractPath.php.

88 : array
89 {
90 if (null === $this->getCidPath()) {
91 return [];
92 }
93
94 // cid array must be ascending, because the
95 // paths should always begin at the baseclass.
96 $cid_array = $this->getCidArray(SORT_ASC);
97 $cid_paths = [];
98
99 foreach ($cid_array as $index => $cid) {
100 $cid_paths[] = (0 !== $index) ?
101 $this->appendCid($cid, $cid_paths[$index - 1]) :
102 $cid
103 ;
104 }
105
106 if (SORT_DESC === $order) {
107 $cid_paths = array_reverse($cid_paths);
108 }
109
110 return $cid_paths;
111 }
appendCid(string $cid, string $path=null)
Helper function to add CIDs to a given path.
$index
Definition: metadata.php:145

References $index, appendCid(), getCidArray(), and getCidPath().

+ Here is the call graph for this function:

◆ getCurrentCid()

ilCtrlAbstractPath::getCurrentCid ( )

@inheritDoc

Implements ilCtrlPathInterface.

Definition at line 56 of file class.ilCtrlAbstractPath.php.

56 : ?string
57 {
58 if (null !== $this->getCidPath()) {
59 // use default order (command- to baseclass) and
60 // retrieve the last command class (index 0).
61 return $this->getCidArray()[0];
62 }
63
64 return null;
65 }

References getCidArray(), and getCidPath().

+ Here is the call graph for this function:

◆ getException()

ilCtrlAbstractPath::getException ( )

@inheritDoc

Implements ilCtrlPathInterface.

Definition at line 149 of file class.ilCtrlAbstractPath.php.

150 {
151 return $this->exception;
152 }
ilCtrl exceptions

References $exception.

◆ getNextCid()

ilCtrlAbstractPath::getNextCid ( string  $current_class)

@inheritDoc

Implements ilCtrlPathInterface.

Definition at line 70 of file class.ilCtrlAbstractPath.php.

70 : ?string
71 {
72 $current_cid = $this->structure->getClassCidByName($current_class);
73 $cid_array = $this->getCidArray(SORT_ASC);
74 $cid_count = count($cid_array);
75
76 foreach ($cid_array as $index => $cid) {
77 if ($current_cid === $cid && ($index + 1) < $cid_count) {
78 return $cid_array[$index + 1];
79 }
80 }
81
82 return null;
83 }

References $index, and getCidArray().

+ Here is the call graph for this function:

◆ getPathToRelatedClassInContext()

ilCtrlAbstractPath::getPathToRelatedClassInContext ( ilCtrlContextInterface  $context,
string  $target_class 
)
protected

Returns the path to a class within the given contexts current path that has a relation to the given target.

Parameters
ilCtrlContextInterface$context
string$target_class
Returns
string|null

Definition at line 162 of file class.ilCtrlAbstractPath.php.

162 : ?string
163 {
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();
169
170 // return the path to the class related to the
171 // target class.
172 return $cid_paths[$index];
173 }
174 }
175 }
176
177 return null;
178 }
isClassChildOf(string $child_class, string $parent_class)
Returns whether the given target class is a child of the other given class.
$context
Definition: webdav.php:29

References $context, $index, and isClassChildOf().

Referenced by ilCtrlArrayClassPath\getCidPathByArray(), and ilCtrlSingleClassPath\getCidPathByClass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isClassChildOf()

ilCtrlAbstractPath::isClassChildOf ( string  $child_class,
string  $parent_class 
)
protected

Returns whether the given target class is a child of the other given class.

Parameters
string$child_class
string$parent_class
Returns
bool

Definition at line 188 of file class.ilCtrlAbstractPath.php.

188 : bool
189 {
190 $children = $this->structure->getChildrenByName($parent_class);
191 if (null !== $children) {
192 return in_array(strtolower($child_class), $children, true);
193 }
194
195 return false;
196 }

Referenced by getPathToRelatedClassInContext().

+ Here is the caller graph for this function:

◆ isClassParentOf()

ilCtrlAbstractPath::isClassParentOf ( string  $parent_class,
string  $child_class 
)
protected

Returns whether the given target class is a parent of the other given class.

Parameters
string$parent_class
string$child_class
Returns
bool

Definition at line 206 of file class.ilCtrlAbstractPath.php.

206 : bool
207 {
208 $parents = $this->structure->getParentsByName($child_class);
209 if (null !== $parents) {
210 return in_array(strtolower($parent_class), $parents, true);
211 }
212
213 return false;
214 }

Referenced by ilCtrlArrayClassPath\getCidPathByArray().

+ Here is the caller graph for this function:

Field Documentation

◆ $cid_path

string ilCtrlAbstractPath::$cid_path = null
protected

◆ $exception

ilCtrlException ilCtrlAbstractPath::$exception = null
protected

◆ $structure


The documentation for this class was generated from the following file: