ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Wrapper.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
16 {
17 
21  protected $components;
22 
26  protected $title = "";
27 
28 
33  public function __construct($url, $content)
34  {
35  parent::__construct($url);
36  $this->components = $this->toArray($content);
37  $types = array( Component::class );
38  $this->checkArgListElements('content', $this->components, $types);
39  $this->checkEmptyArray($this->components);
40  }
41 
42 
46  public function withContent($content)
47  {
48  $clone = clone $this;
49  $clone->components = $this->toArray($content);
50  $types = array( Component::class );
51  $this->checkArgListElements('content', $clone->components, $types);
52  $this->checkEmptyArray($clone->components);
53 
54  return $clone;
55  }
56 
60  public function withTitle($title)
61  {
62  $this->checkStringArg("title", $title);
63  $clone = clone $this;
64  $clone->title = $title;
65 
66  return $clone;
67  }
68 
72  public function getTitle()
73  {
74  return $this->title;
75  }
76 
80  public function getContent()
81  {
82  return $this->components;
83  }
84 
85 
93  private function checkEmptyArray(array $array)
94  {
95  if (count($array) === 0) {
96  throw new \LogicException("At least one component from the UI framework is required, otherwise
97  the wrapper dropzone is not visible.");
98  }
99  }
100 }
trait ComponentHelper
Provides common functionality for component implementations.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
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:93
withContent($content)
Get a wrapper dropzone like this, wrapping around the given component(s).$content$this ...
Definition: Wrapper.php:46
toArray($value)
Wrap the given value in an array if it is no array.
withTitle($title)
Get a wrapper dropzone like this, but showing a custom title in the appearing modal.$content$this
Definition: Wrapper.php:60
getTitle()
Get the custom title if set.Component[]
Definition: Wrapper.php:72