ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
TableDataProvider.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
30 final class TableDataProvider
31 {
32  private Services $irss;
33 
34  public function __construct(
35  private Request $view_request,
36  ) {
37  global $DIC;
38  $this->irss = $DIC->resourceStorage();
39  }
40 
41  public function getViewRequest(): Request
42  {
43  return $this->view_request;
44  }
45 
49  public function getIdentifications(): array
50  {
51  $collection = $this->view_request->getCollection();
52  // Sort
53  $sorter = $this->irss->collection()->sort($collection);
54 
55  switch ($this->view_request->getSortation()) {
57  $collection = $sorter->asc()->byTitle();
58  break;
60  $collection = $sorter->desc()->byTitle();
61  break;
63  $collection = $sorter->asc()->byCreationDate();
64  break;
66  $collection = $sorter->desc()->byCreationDate();
67  break;
69  $collection = $sorter->asc()->bySize();
70  break;
72  $collection = $sorter->desc()->bySize();
73  break;
74  }
75 
76  return $this->irss->collection()->rangeAsArray(
77  $collection,
78  $this->view_request->getPage() * $this->view_request->getItemsPerPage(),
79  $this->view_request->getItemsPerPage(),
80  );
81  }
82 
83  public function getTotal(): int
84  {
85  return $this->view_request->getCollection()->count();
86  }
87 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:22