ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\LearningSequence\Content\Condition\LSOItemNodeRetrieval Class Reference

Provides the objects of a learning sequence as flat list of nodes for tree selects. More...

+ Inheritance diagram for ILIAS\LearningSequence\Content\Condition\LSOItemNodeRetrieval:
+ Collaboration diagram for ILIAS\LearningSequence\Content\Condition\LSOItemNodeRetrieval:

Public Member Functions

 __construct (protected array $items)
 
 getNodes (NodeFactory $node_factory, IconFactory $icon_factory, array $sync_node_id_whitelist=[], ?string $parent_id=null,)
 This method will be called by the tree select input and tree multi select input to generate the tree which is displayed on the client. More...
 
 getNodesAsLeaf (NodeFactory $node_factory, IconFactory $icon_factory, array $node_ids,)
 This method will be called by the UI framework in order to retrieve Leaf instances for provided/submitted values (node-ids). More...
 
 getNodes (NodeFactory $node_factory, IconFactory $icon_factory, array $sync_node_id_whitelist=[], ?string $parent_id=null,)
 This method will be called by the tree select input and tree multi select input to generate the tree which is displayed on the client. More...
 
 getNodesAsLeaf (NodeFactory $node_factory, IconFactory $icon_factory, array $node_ids,)
 This method will be called by the UI framework in order to retrieve Leaf instances for provided/submitted values (node-ids). More...
 

Detailed Description

Provides the objects of a learning sequence as flat list of nodes for tree selects.

Definition at line 30 of file LSOItemNodeRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LearningSequence\Content\Condition\LSOItemNodeRetrieval::__construct ( protected array  $items)
Parameters
\LSItem[]$items

Definition at line 35 of file LSOItemNodeRetrieval.php.

37 {
38 }

Member Function Documentation

◆ getNodes()

ILIAS\LearningSequence\Content\Condition\LSOItemNodeRetrieval::getNodes ( NodeFactory  $node_factory,
IconFactory  $icon_factory,
array  $sync_node_id_whitelist = [],
?string  $parent_id = null 
)

This method will be called by the tree select input and tree multi select input to generate the tree which is displayed on the client.

Parts of the tree can be rendered asynchronously, by generating an

See also
Async node, to indicate that its child-nodes should only be loaded when they are opened/expanded. In this case, the rendering url of the async node will be called from the client, which is expected to generate all child-nodes of the given parent node. This process can recursively continue. Please generate child-nodes during this process by using an instance of this retrieval and provide the appropriate $parent_id parameter.

When this method is provided with a $sync_node_id_whitelist by the UI framework, you MUST generate a complete path from the root to each node (id) in the whitelist. The whitelist is derived from selected node-ids and already contains every node-id on the path leading to a selected node. You can therefore treat it as a "max-depth-whitelist" while building the tree. At every level of these paths all sibling nodes must be included. Sibling branches that are not part of any path MAY be represented as an

See also
Async node.
Parameters
array<string|int>$sync_node_id_whitelist
Returns
\Generator<Node>

Implements ILIAS\UI\Component\Input\Field\Node\NodeRetrieval.

Definition at line 40 of file LSOItemNodeRetrieval.php.

45 : \Generator {
46 if ($parent_id !== null) {
47 return;
48 }
49
50 foreach ($this->items as $item) {
51 $ref_id = (string) $item->getRefId();
52 $obj_id = \ilObject::_lookupObjId((int) $ref_id);
53 $title = \ilObject::_lookupTitle($obj_id);
54 $type = \ilObject::_lookupType($obj_id);
55 $icon = $icon_factory->standard($type, $title);
56 yield $node_factory->leaf(
57 [$ref_id],
58 $title,
59 $icon
60 );
61 }
62 }
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)

◆ getNodesAsLeaf()

ILIAS\LearningSequence\Content\Condition\LSOItemNodeRetrieval::getNodesAsLeaf ( NodeFactory  $node_factory,
IconFactory  $icon_factory,
array  $node_ids 
)

This method will be called by the UI framework in order to retrieve Leaf instances for provided/submitted values (node-ids).

This method MUST yield placeholder instances for invalid node-ids, informing the user about the absence of a given Node.

Parameters
array<string|int>$node_ids
Returns
\Generator<Leaf>

Implements ILIAS\UI\Component\Input\Field\Node\NodeRetrieval.

Definition at line 64 of file LSOItemNodeRetrieval.php.

68 : \Generator {
69 foreach ($node_ids as $node_id) {
70 $ref_id = (string) $node_id;
71 $obj_id = \ilObject::_lookupObjId((int) $ref_id);
72 $title = ($obj_id > 0)
73 ? \ilObject::_lookupTitle($obj_id)
74 : sprintf('Ref-ID %s', $ref_id);
75 $type = ($obj_id > 0)
76 ? \ilObject::_lookupType($obj_id)
77 : '';
78
79 if ($type !== '') {
80 $icon = $icon_factory->standard($type, $title);
81 yield $node_factory->leaf([$ref_id], $title, $icon);
82 continue;
83 }
84
85 yield $node_factory->leaf([$ref_id], $title);
86 }
87 }

References ilObject\_lookupObjId(), ilObject\_lookupTitle(), and ilObject\_lookupType().

+ Here is the call graph for this function:

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