1 | <?php |
||
11 | trait HasViewTrait |
||
12 | { |
||
13 | use AbstractControllerTrait; |
||
14 | |||
15 | /** |
||
16 | * @var View |
||
17 | */ |
||
18 | protected $view; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $layout = 'default'; |
||
24 | |||
25 | public function loadView() |
||
29 | |||
30 | /** |
||
31 | * @return View |
||
32 | */ |
||
33 | public function getView() |
||
41 | |||
42 | /** |
||
43 | * @param View $view |
||
44 | */ |
||
45 | public function setView($view) |
||
49 | |||
50 | /** |
||
51 | * @return View |
||
52 | */ |
||
53 | protected function initView() |
||
60 | |||
61 | /** |
||
62 | * @return View |
||
63 | */ |
||
64 | protected function getViewObject() |
||
68 | |||
69 | /** |
||
70 | * @param View $view |
||
71 | * |
||
72 | * @return View |
||
73 | */ |
||
74 | protected function populateView($view) |
||
83 | |||
84 | /** |
||
85 | * @param View $view |
||
86 | */ |
||
87 | protected function populateViewPath($view) |
||
98 | |||
99 | /** |
||
100 | * @param View $view |
||
101 | * |
||
102 | * @return View |
||
103 | */ |
||
104 | protected function initViewVars($view) |
||
113 | |||
114 | /** |
||
115 | * @param View $view |
||
116 | * |
||
117 | * @return View |
||
118 | */ |
||
119 | protected function initViewContentBlocks($view) |
||
126 | |||
127 | /** |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getLayoutPath() |
||
134 | |||
135 | /** |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getLayout() |
||
142 | |||
143 | /** |
||
144 | * @param string $layout |
||
145 | */ |
||
146 | public function setLayout($layout) |
||
150 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.