ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilBadgeRenderer.php
Go to the documentation of this file.
1 <?php
2 
21 
26 {
27  private readonly ilLanguage $lng;
28  private readonly Renderer $renderer;
29  private readonly Tile $tile;
30  private readonly ?ilBadgeAssignment $assignment;
31  private readonly ilBadge $badge;
32 
33  public function __construct(
34  ilBadgeAssignment $assignment = null,
35  ilBadge $badge = null
36  ) {
37  global $DIC;
38 
39  $this->lng = $DIC->language();
40  $this->renderer = $DIC->ui()->renderer();
41  $this->tile = new Tile($DIC);
42 
43  if ($assignment) {
44  $this->assignment = $assignment;
45  $this->badge = new ilBadge($this->assignment->getBadgeId());
46  } else {
47  $this->assignment = null;
48  $this->badge = $badge;
49  }
50  }
51 
52  public function getHTML(): string
53  {
54  $this->lng->loadLanguageModule('badge');
55  $content = $this->tile->modalContent($this->badge);
56  if ($this->assignment) {
57  $content = $this->tile->addAssignment($content, $this->assignment);
58  }
59 
60  return $this->renderer->render($this->tile->asImage($content));
61  }
62 }
readonly Renderer $renderer
readonly ilBadge $badge
An entity that renders components to a string output.
Definition: Renderer.php:30
readonly ilLanguage $lng
global $DIC
Definition: feed.php:28
__construct(ilBadgeAssignment $assignment=null, ilBadge $badge=null)
readonly ilBadgeAssignment $assignment