ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Badge\BadgeParent Class Reference
+ Collaboration diagram for ILIAS\Badge\BadgeParent:

Public Member Functions

 __construct (private readonly Container $container, $icon=[ilObject::class, '_getIcon'], $references_of=[ilObject::class, '_getAllReferences'], $link_to=[ilLink::class, '_getLink'])
 
 asComponent (ilBadge $badge)
 
 asProperty (ilBadge $badge)
 

Private Member Functions

 metaData (ilBadge $badge)
 

Private Attributes

readonly Closure $icon
 
readonly Closure $references_of
 
readonly Closure $link_to
 

Detailed Description

Definition at line 30 of file BadgeParent.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Badge\BadgeParent::__construct ( private readonly Container  $container,
  $icon = [ilObject::class, '_getIcon'],
  $references_of = [ilObject::class, '_getAllReferences'],
  $link_to = [ilLink::class, '_getLink'] 
)
Parameters
Closure(int,string,string)string $icon
Closure(int)int[] $references_of
Closure(int)string $link_to

Definition at line 44 of file BadgeParent.php.

49 {
50 $this->icon = Closure::fromCallable($icon);
51 $this->references_of = Closure::fromCallable($references_of);
52 $this->link_to = Closure::fromCallable($link_to);
53 }
readonly Closure $references_of
Definition: BadgeParent.php:35
readonly Closure $icon
Definition: BadgeParent.php:33
readonly Closure $link_to
Definition: BadgeParent.php:37

References ILIAS\Badge\BadgeParent\$icon, ILIAS\Badge\BadgeParent\$link_to, and ILIAS\Badge\BadgeParent\$references_of.

Member Function Documentation

◆ asComponent()

ILIAS\Badge\BadgeParent::asComponent ( ilBadge  $badge)

Definition at line 55 of file BadgeParent.php.

55 : ?Component
56 {
57 $meta_data = $this->metaData($badge);
58 if (null === $meta_data) {
59 return null;
60 }
61
62 $parent_icon = $this->container->ui()->factory()->symbol()->icon()->custom(
63 ($this->icon)($meta_data['id'], 'big', $meta_data['type']),
64 $this->container->language()->txt('obj_' . $meta_data['type']),
65 'medium'
66 );
67
68 $parent_ref_id = current(($this->references_of)($meta_data['id']));
69 if ($parent_ref_id && $this->container->access()->checkAccess('read', '', $parent_ref_id)) {
70 $parent_link = $this->container->ui()
71 ->factory()
72 ->link()
73 ->standard($meta_data['title'], ($this->link_to)($parent_ref_id));
74 } else {
75 $parent_link = $this->container->ui()->factory()->legacy()->content($meta_data['title']);
76 }
77
78 return $this->container->ui()->factory()->listing()->descriptive([
79 $this->container->language()->txt('object') => $this->container->ui()->factory()->legacy()->content(
80 $this->container->ui()->renderer()->render([$parent_icon, $parent_link])
81 )
82 ]);
83 }
metaData(ilBadge $badge)

References ILIAS\Badge\BadgeParent\metaData().

Referenced by ILIAS\Badge\Tile\inDeck().

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

◆ asProperty()

ILIAS\Badge\BadgeParent::asProperty ( ilBadge  $badge)

Definition at line 85 of file BadgeParent.php.

85 : ?string
86 {
87 $meta_data = $this->metaData($badge);
88 if (null === $meta_data) {
89 return null;
90 }
91
92 $icon = [$this->container->ui()->factory()->symbol()->icon(), 'custom'];
93
94 return implode(' ', [
95 $this->container->ui()->renderer()->render($icon(($this->icon)($meta_data['id'], 'small', $meta_data['type']), $meta_data['title'])),
96 $meta_data['title'],
97 ]);
98 }

References ILIAS\Badge\BadgeParent\$icon, and ILIAS\Badge\BadgeParent\metaData().

+ Here is the call graph for this function:

◆ metaData()

ILIAS\Badge\BadgeParent::metaData ( ilBadge  $badge)
private

Definition at line 100 of file BadgeParent.php.

100 : ?array
101 {
102 if (!$badge->getParentId()) {
103 return null;
104 }
105 $parent = $badge->getParentMeta();
106 if ($parent['type'] === 'bdga') {
107 return null;
108 }
109
110 return $parent;
111 }

References ilBadge\getParentId(), and ilBadge\getParentMeta().

Referenced by ILIAS\Badge\BadgeParent\asComponent(), and ILIAS\Badge\BadgeParent\asProperty().

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

Field Documentation

◆ $icon

readonly Closure ILIAS\Badge\BadgeParent::$icon
private

◆ $link_to

readonly Closure ILIAS\Badge\BadgeParent::$link_to
private

Definition at line 37 of file BadgeParent.php.

Referenced by ILIAS\Badge\BadgeParent\__construct().

◆ $references_of

readonly Closure ILIAS\Badge\BadgeParent::$references_of
private

Definition at line 35 of file BadgeParent.php.

Referenced by ILIAS\Badge\BadgeParent\__construct().


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