ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 {
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}
An exception for terminatinating execution or to throw for unit testing.
getTitle()
Get the custom title if set.Component[]
Definition: Wrapper.php:72
checkEmptyArray(array $array)
Checks if the passed array contains at least one element, throws a LogicException otherwise.
Definition: Wrapper.php:93
withTitle($title)
Get a wrapper dropzone like this, but showing a custom title in the appearing modal....
Definition: Wrapper.php:60
withContent($content)
Get a wrapper dropzone like this, wrapping around the given component(s).$this
Definition: Wrapper.php:46
A component is the most general form of an entity in the UI.
Definition: Component.php:14
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
toArray($value)
Wrap the given value in an array if it is no array.
checkArgListElements($which, array &$values, $classes)
Check every element of the list if it is an instance of one of the given classes.
trait ComponentHelper
Provides common functionality for component implementations.