1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\traits; |
4
|
|
|
use Ajax\common\components\GenericComponent; |
5
|
|
|
use Ajax\semantic\components\Popup; |
6
|
|
|
use Ajax\semantic\components\Dropdown; |
7
|
|
|
use Ajax\semantic\components\Accordion; |
8
|
|
|
use Ajax\common\components\SimpleComponent; |
9
|
|
|
use Ajax\semantic\components\Sticky; |
10
|
|
|
use Ajax\semantic\components\Checkbox; |
11
|
|
|
trait SemanticComponentsTrait { |
12
|
|
|
|
13
|
|
|
public abstract function addComponent(SimpleComponent $component, $attachTo, $params); |
14
|
|
|
/** |
15
|
|
|
* |
16
|
|
|
* @param string $attachTo |
17
|
|
|
* @param string|array $params |
18
|
|
|
* @return GenericComponent |
19
|
|
|
*/ |
20
|
|
|
public function generic($attachTo=NULL, $params=NULL) { |
21
|
|
|
return $this->addComponent(new GenericComponent($this->js), $attachTo, $params); |
|
|
|
|
22
|
|
|
} |
23
|
|
|
/** |
24
|
|
|
* |
25
|
|
|
* @param string $attachTo |
26
|
|
|
* @param string|array $params |
27
|
|
|
* @return Popup |
28
|
|
|
*/ |
29
|
|
|
public function popup($attachTo=NULL, $params=NULL) { |
30
|
|
|
return $this->addComponent(new Popup($this->js), $attachTo, $params); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string $attachTo |
35
|
|
|
* @param string|array $params |
36
|
|
|
* @return Dropdown |
37
|
|
|
*/ |
38
|
|
|
public function dropdown($attachTo=NULL, $params=NULL) { |
39
|
|
|
return $this->addComponent(new Dropdown($this->js), $attachTo, $params); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param string $attachTo |
44
|
|
|
* @param string|array $params |
45
|
|
|
* @return Accordion |
46
|
|
|
*/ |
47
|
|
|
public function accordion($attachTo=NULL, $params=NULL) { |
48
|
|
|
return $this->addComponent(new Accordion($this->js), $attachTo, $params); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function sticky($attachTo=NULL, $params=NULL) { |
52
|
|
|
return $this->addComponent(new Sticky($this->js), $attachTo, $params); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function checkbox($attachTo=NULL, $params=NULL) { |
56
|
|
|
return $this->addComponent(new Checkbox($this->js), $attachTo, $params); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: