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