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
|
|
|
trait SemanticComponentsTrait { |
11
|
|
|
|
12
|
|
|
public abstract function addComponent(SimpleComponent $component, $attachTo, $params); |
13
|
|
|
/** |
14
|
|
|
* |
15
|
|
|
* @param string $attachTo |
16
|
|
|
* @param string|array $params |
17
|
|
|
* @return GenericComponent |
18
|
|
|
*/ |
19
|
|
|
public function generic($attachTo=NULL, $params=NULL) { |
20
|
|
|
return $this->addComponent(new GenericComponent($this->js), $attachTo, $params); |
|
|
|
|
21
|
|
|
} |
22
|
|
|
/** |
23
|
|
|
* |
24
|
|
|
* @param string $attachTo |
25
|
|
|
* @param string|array $params |
26
|
|
|
* @return Popup |
27
|
|
|
*/ |
28
|
|
|
public function popup($attachTo=NULL, $params=NULL) { |
29
|
|
|
return $this->addComponent(new Popup($this->js), $attachTo, $params); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $attachTo |
34
|
|
|
* @param string|array $params |
35
|
|
|
* @return Dropdown |
36
|
|
|
*/ |
37
|
|
|
public function dropdown($attachTo=NULL, $params=NULL) { |
38
|
|
|
return $this->addComponent(new Dropdown($this->js), $attachTo, $params); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $attachTo |
43
|
|
|
* @param string|array $params |
44
|
|
|
* @return Accordion |
45
|
|
|
*/ |
46
|
|
|
public function accordion($attachTo=NULL, $params=NULL) { |
47
|
|
|
return $this->addComponent(new Accordion($this->js), $attachTo, $params); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function sticky($attachTo=NULL, $params=NULL) { |
51
|
|
|
return $this->addComponent(new Sticky($this->js), $attachTo, $params); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
} |
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: