ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ComponentFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Factory as UIFactory;
26use ILIAS\Data\Factory as DataFactory;
29use ILIAS\MetaData\Presentation\UtilitiesInterface as PresentationUtilities;
30
32{
33 public function __construct(
34 protected UIFactory $ui_factory,
35 protected DataFactory $data_factory,
36 protected LinkFactoryInterface $link_factory,
37 protected PresentationUtilities $presentation_utilities
38 ) {
39 }
40
44 public function getButtonToControlCenter(
45 Status $status,
46 int $ref_id,
47 int $obj_id,
48 string $type
49 ): array {
50 $view_link = $this->data_factory->uri(
51 rtrim(ILIAS_HTTP_PATH, '/') . '/' .
52 ltrim($this->link_factory->getViewLink($ref_id, $obj_id, $type), '/')
53 );
54 $prompt = $this->ui_factory->prompt()->standard($view_link);
55 $button = $this->ui_factory->button()->standard($this->getButtonLabel(), $prompt->getShowSignal());
56 $message = $this->ui_factory->messageBox()->info($this->getStatusInfo($status))->withButtons([$button]);
57 return [$message, $prompt];
58 }
59
60 protected function getButtonLabel(): string
61 {
62 return $this->presentation_utilities->txt('md_publishing_control_center');
63 }
64
65 protected function getStatusInfo(Status $status): string
66 {
67 $status_label = match ($status) {
68 Status::UNPUBLISHED => $this->presentation_utilities->txt('md_publishing_status_unpublished'),
69 Status::BLOCKED => $this->presentation_utilities->txt('md_publishing_status_blocked'),
70 Status::UNDER_REVIEW => $this->presentation_utilities->txt('md_publishing_status_under_review'),
71 Status::PUBLISHED => $this->presentation_utilities->txt('md_publishing_status_published')
72 };
73 return $this->presentation_utilities->txtFill('md_publishing_current_status', $status_label);
74 }
75}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
getButtonToControlCenter(Status $status, int $ref_id, int $obj_id, string $type)
__construct(protected UIFactory $ui_factory, protected DataFactory $data_factory, protected LinkFactoryInterface $link_factory, protected PresentationUtilities $presentation_utilities)
$ref_id
Definition: ltiauth.php:66