ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
LinkList.php
Go to the documentation of this file.
2 
13 
19 {
21  use hasSymbolTrait;
23 
27  protected $title = '';
31  protected $links;
35  protected $supports_async_loading = false;
36 
41  public function withTitle(string $title) : hasTitle
42  {
43  $clone = clone($this);
44  $clone->title = $title;
45 
46  return $clone;
47  }
48 
52  public function getTitle() : string
53  {
54  return $this->title;
55  }
56 
61  public function withLinks($links) : LinkList
62  {
63  if (is_callable($links)) {
64  try {
65  $r = new \ReflectionFunction($links);
66  if ($r->isGenerator()) {
67  $links = iterator_to_array($links());
68  } else {
69  $links = $links();
70  }
71  } catch (\ReflectionException $e) {
72  $links = false;
73  }
74 
75  if (!is_array($links)) {
76  throw new InvalidArgumentException("withLinks only accepts arrays of Links or a callable providing them");
77  }
78  }
79  foreach ($links as $link) {
80  if (!$link instanceof Link) {
81  throw new InvalidArgumentException("withLinks only accepts arrays of Links or a callable providing them");
82  }
83  }
84  $clone = clone($this);
85  $clone->links = $links;
86 
87  return $clone;
88  }
89 
93  public function getLinks() : array
94  {
95  return $this->links;
96  }
97 
102  {
103  $clone = clone($this);
104  $clone->supports_async_loading = $supported;
105 
106  return $clone;
107  }
108 
112  public function supportsAsynchronousLoading() : bool
113  {
115  }
116 
117  public function isVisible() : bool
118  {
119  $visible_links = 0;
120  foreach ($this->getLinks() as $link) {
121  if ($link->isVisible()) {
122  $visible_links++;
123  }
124  }
125  return $visible_links > 0 && parent::isVisible();
126  }
127 
128 }
Interface hasSymbol Methods for Entries with Symbols.
Definition: hasSymbol.php:11
trait hasSymbolTrait
Trait hasSymbolTrait.