ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LinkList.php
Go to the documentation of this file.
2 
6 
12 class LinkList extends AbstractChildItem implements hasTitle
13 {
14 
18  protected $title = '';
22  protected $links;
23 
24 
30  public function withTitle(string $title) : hasTitle
31  {
32  $clone = clone($this);
33  $clone->title = $title;
34 
35  return $clone;
36  }
37 
38 
42  public function getTitle() : string
43  {
44  return $this->title;
45  }
46 
47 
53  public function withLinks($links) : LinkList
54  {
55  if (is_callable($links)) {
56  $links = $links();
57  if (!is_array($links)) {
58  throw new InvalidArgumentException("withLinks only accepts arrays of Links or a callable providing them");
59  }
60  }
61  foreach ($links as $link) {
62  if (!$link instanceof Link) {
63  throw new InvalidArgumentException("withLinks only accepts arrays of Links or a callable providing them");
64  }
65  }
66  $clone = clone($this);
67  $clone->links = $links;
68 
69  return $clone;
70  }
71 
72 
76  public function getLinks() : array
77  {
78  return $this->links;
79  }
80 }