ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
RequestToDeckOfCards.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
33 {
34  use RIDHelper;
35 
36  private \ILIAS\ResourceStorage\Services $irss;
37 
38  public function __construct(
39  private Request $request,
40  private Factory $ui_factory,
41  private \ilLanguage $language,
42  private Services $http,
43  private TableDataProvider $data_provider,
44  private ActionBuilder $action_builder,
45  private ViewControlBuilder $view_control_builder,
46  private UploadBuilder $upload_builder
47  ) {
48  global $DIC;
49  $this->irss = $DIC->resourceStorage();
50  }
51 
52  protected function buildDeck(): Deck
53  {
54  $this->initCardsPerPage();
55 
56  $cards = [];
57  foreach ($this->data_provider->getIdentifications() as $resource_identification) {
58  $revision_to_card = new RevisionToComponent($this->getCurrentRevision($resource_identification));
59  $cards[] = $revision_to_card->getAsCard()
60  ->withActions(
61  $this->action_builder->buildDropDownForResource($resource_identification)
62  );
63  }
64 
65  return $this->ui_factory->deck($cards)->withSmallCardsSize();
66  }
67 
68  protected function initCardsPerPage(): void
69  {
70  $cards_per_row = 6;
71  $items_per_page = (int) ceil($this->request->getItemsPerPage() / ($cards_per_row ** 1)) * ($cards_per_row ** 1);
72  $this->request->setItemsPerPage($items_per_page);
73  }
74 
75  public function getComponents(): \Generator
76  {
77  yield from $this->upload_builder->getDropZone();
78 
79  yield $this->ui_factory->panel()
80  ->standard($this->request->getTitle(), $this->buildDeck())
81  ->withViewControls([
82  $this->view_control_builder->getPagination(),
83  $this->view_control_builder->getSortation()
84  ]);
85  // Modals must be rendered after the deck, otherwise there are no modals
86  yield from $this->action_builder->getModals();
87  }
88 }
__construct(private Request $request, private Factory $ui_factory, private \ilLanguage $language, private Services $http, private TableDataProvider $data_provider, private ActionBuilder $action_builder, private ViewControlBuilder $view_control_builder, private UploadBuilder $upload_builder)
$http
Definition: deliver.php:30
This is how the factory for UI elements looks.
Definition: Factory.php:37
global $DIC
Definition: shib_login.php:22