ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Card.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Amstutz Timon <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4 
6 
9 
10 class Card implements C\Card
11 {
12  use ComponentHelper;
13 
17  protected $title;
18 
22  protected $header_section;
23 
27  protected $content_sections;
28 
32  protected $image;
33 
37  protected $title_url = '';
38 
42  protected $image_url = '';
43 
47  protected $highlight = false;
48 
53  public function __construct($title, \ILIAS\UI\Component\Image\Image $image = null)
54  {
55  if (!$title instanceof \ILIAS\UI\Component\Button\Shy) {
56  $this->checkStringArg("title", $title);
57  }
58 
59  $this->title = $title;
60  $this->image = $image;
61  }
62 
66  public function withTitle($title)
67  {
68  if (!$title instanceof \ILIAS\UI\Component\Button\Shy) {
69  $this->checkStringArg("title", $title);
70  }
71 
72  $clone = clone $this;
73  $clone->title = $title;
74 
75  return $clone;
76  }
77 
81  public function getTitle()
82  {
83  return $this->title;
84  }
85 
90  {
91  $clone = clone $this;
92  $clone->image = $image;
93  return $clone;
94  }
95 
99  public function getImage()
100  {
101  return $this->image;
102  }
103 
107  public function withSections(array $sections)
108  {
109  $classes = [\ILIAS\UI\Component\Component::class];
110  $this->checkArgListElements("sections", $sections, $classes);
111 
112  $clone = clone $this;
113  $clone->content_sections = $sections;
114  return $clone;
115  }
116 
120  public function getSections()
121  {
123  }
124 
128  public function withTitleAction($url)
129  {
130  $this->checkStringArg("title_url", $url);
131 
132  $clone = clone $this;
133  $clone->title_url = $url;
134 
135  return $clone;
136  }
137 
141  public function getTitleAction()
142  {
143  return $this->title_url;
144  }
145 
149  public function withImageAction($url)
150  {
151  $this->checkStringArg("title_url", $url);
152 
153  $clone = clone $this;
154  $clone->image_url = $url;
155 
156  return $clone;
157  }
158 
162  public function getImageAction()
163  {
164  return $this->image_url;
165  }
166 
167 
171  public function withHighlight($status)
172  {
173  $clone = clone $this;
174  $clone->highlight = $status;
175 
176  return $clone;
177  }
178 
182  public function isHighlighted()
183  {
184  return $this->highlight;
185  }
186 }
Class Factory.
Class BaseForm.
trait ComponentHelper
Provides common functionality for component implementations.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
withImage(\ILIAS\UI\Component\Image\Image $image)
Definition: Card.php:89
checkArgListElements($which, array &$values, &$classes)
Check every element of the list if it is an instance of one of the given classes. ...
__construct($title, \ILIAS\UI\Component\Image\Image $image=null)
Definition: Card.php:53
$url