ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Modal.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Badge;
22
24use Closure;
27
28class 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
item(ModalContent $content)
Definition: Modal.php:65
ilBadgeImage $badge_image_service
Definition: Modal.php:32
__construct(private readonly Container $container, $sign_file=[ilWACSignedPath::class, 'signFile'])
Definition: Modal.php:34
components(ModalContent $content)
Definition: Modal.php:49
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Class ilWACSignedPath.
A component is the most general form of an entity in the UI.
Definition: Component.php:28
$container
@noRector
Definition: wac.php:37