ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Descriptive.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4 
6 
7 use ILIAS\UI\Component as C;
9 
14 class Descriptive implements C\Listing\Descriptive
15 {
16  use ComponentHelper;
17 
21  private $items;
22 
26  public function __construct(array $items)
27  {
28  $this->checkArgList(
29  "Descriptive List items",
30  $items,
31  function ($k, $v) {
32  return is_string($k) && (is_string($v) || $v instanceof C\Component);
33  },
34  function ($k, $v) {
35  return "expected keys of type string and values of type string|Component, got ($k => $v)";
36  }
37  );
38 
39  $this->items = $items;
40  }
41 
45  public function withItems(array $items)
46  {
47  $this->checkArgList(
48  "Descriptive List items",
49  $items,
50  function ($k, $v) {
51  return is_string($k) && (is_string($v) || $v instanceof C\Component);
52  },
53  function ($k, $v) {
54  return "expected keys of type string and values of type string|Component, got ($k => $v)";
55  }
56  );
57 
58  $clone = clone $this;
59  $clone->items = $items;
60  return $clone;
61  }
62 
66  public function getItems()
67  {
68  return $this->items;
69  }
70 }
trait ComponentHelper
Provides common functionality for component implementations.
A component is the most general form of an entity in the UI.
Definition: Component.php:13
checkArgList($which, array &$values, \Closure $check, \Closure $message)
Check every key and value of the list with a supplied closure.
Create styles array
The data for the language used.