ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
13 
20 function base()
21 {
22  global $DIC;
23  $f = $DIC->ui()->factory();
24  $renderer = $DIC->ui()->renderer();
25 
26  $record_to_entity = new class () implements RecordToEntity {
27  public function map(UIFactory $ui_factory, mixed $record): Entity
28  {
29  list($abbreviation, $login, $email, $name, $last_seen, $active) = $record;
30  $avatar = $ui_factory->symbol()->avatar()->letter($abbreviation);
31  return $ui_factory->entity()->standard($name, $avatar)
33  $ui_factory->listing()->property()
34  ->withProperty('login', $login)
35  ->withProperty('mail', $email, false)
36  )
37  ->withDetails(
38  $ui_factory->listing()->property()
39  ->withItems([
40  ['last seen', $last_seen],
41  ['active', $active ? 'yes' : 'no'],
42  ])
43  );
44  }
45  };
46 
47  $data = new class () implements DataRetrieval {
48  protected $data = [
49  ['jw', 'jimmywilson','jimmywilson@example.com', 'Jimmy Wilson', '2022-03-15 13:20:10', true],
50  ['eb', 'emilybrown','emilybrown@example.com','Emily Brown','2022-03-16 10:45:32', false],
51  ['ms', 'michaelscott','michaelscott@example.com','Michael Scott','2022-03-14 08:15:05', true],
52  ['kj', 'katiejones','katiejones@example.com','Katie Jones','2022-03-17 15:30:50',true]
53  ];
54 
55  public function getEntities(
56  Mapping $mapping,
57  ?Range $range,
58  ?array $additional_parameters
59  ): \Generator {
60  foreach ($this->data as $usr) {
61  yield $mapping->map($usr);
62  }
63  }
64  };
65 
66  $listing = $f->listing()->entity()->standard($record_to_entity)
67  ->withData($data);
68 
69  return $renderer->render($listing);
70 }
This describes an Entity.
Definition: Entity.php:36
$renderer
withMainDetails(PropertyListing|Legacy ... $main_details)
Main Details should provide a quick differentiation or choice on the entity.
base()
expected output: > ILIAS shows the rendered Component.
Definition: base.php:20
This is to accumulate/consolidate the data to be shown in the listing.
global $DIC
Definition: shib_login.php:25
Listings will have to map records to Entities.
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
Hand a record over to RecordToEntity and factor an Entity.
Definition: Mapping.php:28