ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Modal.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Badge;
22 
24 use Closure;
26 use ilWACSignedPath;
27 
28 class Modal
29 {
31  private readonly Closure $sign_file;
33 
34  public function __construct(
35  private readonly Container $container,
36  $sign_file = [ilWACSignedPath::class, 'signFile']
37  ) {
38  $this->sign_file = Closure::fromCallable($sign_file);
39  $this->badge_image_service = new ilBadgeImage(
40  $container->resourceStorage(),
41  $container->upload(),
42  $container->ui()->mainTemplate()
43  );
44  }
45 
49  public function components(ModalContent $content): array
50  {
51  $modal_content = [];
52 
53  $image_src = $this->badge_image_service->getImageFromBadge($content->badge(), ilBadgeImage::IMAGE_SIZE_XL);
54 
55  $modal_content[] = $this->container->ui()->factory()->image()->responsive(
56  $image_src,
57  $content->badge()->getTitle()
58  );
59  $modal_content[] = $this->container->ui()->factory()->divider()->horizontal();
60  $modal_content[] = $this->item($content);
61 
62  return $modal_content;
63  }
64 
65  private function item(ModalContent $content): Component
66  {
67  return $this->container
68  ->ui()
69  ->factory()
70  ->item()
71  ->standard($content->badge()->getTitle())
72  ->withDescription($content->badge()->getDescription())
73  ->withProperties($content->properties());
74  }
75 }
readonly Closure $sign_file
Definition: Modal.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBadgeImage $badge_image_service
Definition: Modal.php:32
$container
Definition: wac.php:36
__construct(private readonly Container $container, $sign_file=[ilWACSignedPath::class, 'signFile'])
Definition: Modal.php:34
components(ModalContent $content)
Definition: Modal.php:49
item(ModalContent $content)
Definition: Modal.php:65