ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
OverviewActionGenerator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
32 {
33  private \ILIAS\UI\Factory $ui_factory;
34  private \ilLanguage $language;
35  private \ilCtrlInterface $ctrl;
36  private array $collected_modals = [];
37  private \ILIAS\ResourceStorage\Services $irss;
38 
39  public function __construct()
40  {
41  global $DIC;
42  $this->ui_factory = $DIC->ui()->factory();
43  $this->language = $DIC->language();
44  $this->ctrl = $DIC->ctrl();
45  $this->irss = $DIC->resourceStorage();
46  }
47 
48  public function getActionsForRevision(
49  Revision $revision
50  ): array {
51  $this->ctrl->setParameterByClass(
52  \ilResourceOverviewGUI::class,
54  $revision->getIdentification()->serialize()
55  );
56  $actions = [
57  $this->ui_factory->button()->shy(
58  $this->language->txt('action_show_revisions'),
59  $this->ctrl->getLinkTargetByClass(
60  \ilResourceOverviewGUI::class,
62  )
63  ),
64  $this->ui_factory->button()->shy(
65  $this->language->txt('action_goto'),
66  $this->ctrl->getLinkTargetByClass(
67  \ilResourceOverviewGUI::class,
69  )
70  ),
71  $this->ui_factory->button()->shy(
72  $this->language->txt('action_download'),
73  $this->ctrl->getLinkTargetByClass(
74  \ilResourceOverviewGUI::class,
76  )
77  ),
78  ];
79  $resource = $this->irss->manage()->getResource($revision->getIdentification());
80  if ($resource->getStakeholders() === []) {
81  $this->collected_modals[] = $modal = $this->getRemoveConfirmationModal($revision);
82  $actions[] = $this->ui_factory->button()->shy(
83  $this->language->txt('action_remove_resource'),
84  '#'
85  )->withOnClick($modal->getShowSignal());
86  }
87 
88  return $actions;
89  }
90 
91 
92  public function getCollectedModals(): array
93  {
95  }
96 
97 
98  private function getRemoveConfirmationModal(Revision $revision): Modal
99  {
100  $action = $this->ctrl->getLinkTargetByClass(
101  \ilResourceOverviewGUI::class,
103  );
104  return $this->ui_factory->modal()->interruptive(
106  $this->language->txt('confirm_delete'),
107  $action
108  )->withAffectedItems([
109  $this->ui_factory->modal()->interruptiveItem()->standard(
110  $revision->getIdentification()->serialize(),
111  $revision->getInformation()->getTitle(),
112  )
113  ]);
114  }
115 }
This describes commonalities between the different modals.
Definition: Modal.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28