ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
36 function base()
37 {
38  global $DIC;
39  $f = $DIC->ui()->factory();
40  $renderer = $DIC->ui()->renderer();
41 
42  $record_to_entity = new class () implements RecordToEntity {
43  public function map(UIFactory $ui_factory, mixed $record): Entity
44  {
45  list($abbreviation, $login, $email, $name, $last_seen, $active) = $record;
46  $avatar = $ui_factory->symbol()->avatar()->letter($abbreviation);
47  return $ui_factory->entity()->standard($name, $avatar)
49  $ui_factory->listing()->property()
50  ->withProperty('login', $login)
51  ->withProperty('mail', $email, false)
52  )
53  ->withDetails(
54  $ui_factory->listing()->property()
55  ->withItems([
56  ['last seen', $last_seen],
57  ['active', $active ? 'yes' : 'no'],
58  ])
59  );
60  }
61  };
62 
63  $data = new class () implements DataRetrieval {
64  protected $data = [
65  ['jw', 'jimmywilson','jimmywilson@example.com', 'Jimmy Wilson', '2022-03-15 13:20:10', true],
66  ['eb', 'emilybrown','emilybrown@example.com','Emily Brown','2022-03-16 10:45:32', false],
67  ['ms', 'michaelscott','michaelscott@example.com','Michael Scott','2022-03-14 08:15:05', true],
68  ['kj', 'katiejones','katiejones@example.com','Katie Jones','2022-03-17 15:30:50',true]
69  ];
70 
71  public function getEntities(
72  Mapping $mapping,
73  ?Range $range,
74  ?array $additional_parameters
75  ): \Generator {
76  foreach ($this->data as $usr) {
77  yield $mapping->map($usr);
78  }
79  }
80  };
81 
82  $listing = $f->listing()->entity()->standard($record_to_entity)
83  ->withData($data);
84 
85  return $renderer->render($listing);
86 }
This describes an Entity.
Definition: Entity.php:36
$renderer
withMainDetails(PropertyListing|Content ... $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:36
This is to accumulate/consolidate the data to be shown in the listing.
global $DIC
Definition: shib_login.php:22
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