ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Wrapper.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
16 {
17 
21  protected $components;
22 
23 
28  public function __construct($url, $content)
29  {
30  parent::__construct($url);
31  $this->components = $this->toArray($content);
32  $types = array( Component::class );
33  $this->checkArgListElements('content', $this->components, $types);
34  $this->checkEmptyArray($this->components);
35  }
36 
37 
41  public function withContent($content)
42  {
43  $clone = clone $this;
44  $clone->components = $this->toArray($content);
45  $types = array( Component::class );
46  $this->checkArgListElements('content', $clone->components, $types);
47  $this->checkEmptyArray($clone->components);
48 
49  return $clone;
50  }
51 
52 
56  public function getContent()
57  {
58  return $this->components;
59  }
60 
61 
69  private function checkEmptyArray(array $array)
70  {
71  if (count($array) === 0) {
72  throw new \LogicException("At least one component from the UI framework is required, otherwise
73  the wrapper dropzone is not visible.");
74  }
75  }
76 }
trait ComponentHelper
Provides common functionality for component implementations.
checkArgListElements($which, array &$values, &$classes)
Check every element of the list if it is an instance of one of the given classes. ...
checkEmptyArray(array $array)
Checks if the passed array contains at least one element, throws a LogicException otherwise...
Definition: Wrapper.php:69
Create styles array
The data for the language used.
withContent($content)
Get a wrapper dropzone like this, wrapping around the given component(s).$content$this ...
Definition: Wrapper.php:41
toArray($value)
Wrap the given value in an array if it is no array.