ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBadgeRenderer.php
Go to the documentation of this file.
1<?php
2
21
23{
24 private readonly ilLanguage $lng;
25 private readonly Renderer $renderer;
26 private readonly Tile $tile;
27 private readonly ?ilBadgeAssignment $assignment;
28 private readonly ilBadge $badge;
29
30 public function __construct(
32 ?ilBadge $badge = null
33 ) {
34 global $DIC;
35
36 $this->lng = $DIC->language();
37 $this->renderer = $DIC->ui()->renderer();
38 $this->tile = new Tile($DIC);
39
40 if ($assignment) {
41 $this->assignment = $assignment;
42 $this->badge = new ilBadge($this->assignment->getBadgeId());
43 } else {
44 $this->assignment = null;
45 $this->badge = $badge;
46 }
47 }
48
49 public function getHTML(): string
50 {
51 $this->lng->loadLanguageModule('badge');
52 $content = $this->tile->modalContent($this->badge);
53 if ($this->assignment) {
54 $content = $this->tile->addAssignment($content, $this->assignment);
55 }
56
57 return $this->renderer->render($this->tile->asImage($content));
58 }
59}
renderer()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly Renderer $renderer
readonly ilBadgeAssignment $assignment
readonly ilBadge $badge
__construct(?ilBadgeAssignment $assignment=null, ?ilBadge $badge=null)
readonly ilLanguage $lng
language handling
An entity that renders components to a string output.
Definition: Renderer.php:31
global $DIC
Definition: shib_login.php:26