1 | <?php |
||
13 | abstract class AbstractWidgetFactory |
||
14 | { |
||
15 | use ViewExpressionTrait; |
||
16 | |||
17 | /** |
||
18 | * Widget object to work with. |
||
19 | * |
||
20 | * @var AbstractWidget |
||
21 | */ |
||
22 | protected $widget; |
||
23 | |||
24 | /** |
||
25 | * Widget configuration array. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $widgetConfig; |
||
30 | |||
31 | /** |
||
32 | * The name of the widget being called. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | public $widgetName; |
||
37 | |||
38 | /** |
||
39 | * Custom widget namespace of the widget being called if is set. |
||
40 | * |
||
41 | * @var string|null |
||
42 | */ |
||
43 | public $customWidgetNamespace; |
||
44 | |||
45 | /** |
||
46 | * Array of widget parameters excluding the first one (config). |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | public $widgetParams; |
||
51 | |||
52 | /** |
||
53 | * Array of widget parameters including the first one (config). |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | public $widgetFullParams; |
||
58 | |||
59 | /** |
||
60 | * Laravel application wrapper for better testability. |
||
61 | * |
||
62 | * @var ApplicationWrapperContract; |
||
63 | */ |
||
64 | public $app; |
||
65 | |||
66 | /** |
||
67 | * Another factory that produces some javascript. |
||
68 | * |
||
69 | * @var JavascriptFactory |
||
70 | */ |
||
71 | protected $javascriptFactory; |
||
72 | |||
73 | /** |
||
74 | * The flag for not wrapping content in a special container. |
||
75 | * |
||
76 | * @var bool |
||
77 | */ |
||
78 | public static $skipWidgetContainer = false; |
||
79 | |||
80 | /** |
||
81 | * The flag for not wrapping content in a special container. |
||
82 | * |
||
83 | * @var bool |
||
84 | */ |
||
85 | public static $allowOnlyWidgetsWithDisabledEncryption = false; |
||
86 | |||
87 | /** |
||
88 | * Constructor. |
||
89 | * |
||
90 | * @param ApplicationWrapperContract $app |
||
91 | */ |
||
92 | public function __construct(ApplicationWrapperContract $app) |
||
98 | |||
99 | /** |
||
100 | * Magic method that catches all widget calls. |
||
101 | * |
||
102 | * @param string $widgetName |
||
103 | * @param array $params |
||
104 | * |
||
105 | * @return mixed |
||
106 | */ |
||
107 | public function __call($widgetName, array $params = []) |
||
113 | |||
114 | /** |
||
115 | * Set class properties and instantiate a widget object. |
||
116 | * |
||
117 | * @param $params |
||
118 | * |
||
119 | * @throws InvalidWidgetClassException |
||
120 | * @throws EncryptException |
||
121 | */ |
||
122 | protected function instantiateWidget(array $params = []) |
||
162 | |||
163 | /** |
||
164 | * Convert stuff like 'profile.feedWidget' to 'Profile\FeedWidget'. |
||
165 | * |
||
166 | * @param $widgetName |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | protected function parseFullWidgetNameFromString($widgetName) |
||
174 | |||
175 | /** |
||
176 | * Wrap the given content in a container if it's not an ajax call. |
||
177 | * |
||
178 | * @param $content |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | protected function wrapContentInContainer($content) |
||
195 | |||
196 | /** |
||
197 | * Encrypt widget params to be transported via HTTP. |
||
198 | * |
||
199 | * @param string $params |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | public function encryptWidgetParams($params) |
||
207 | |||
208 | /** |
||
209 | * Decrypt widget params that were transported via HTTP. |
||
210 | * |
||
211 | * @param string $params |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | public function decryptWidgetParams($params) |
||
219 | |||
220 | /** |
||
221 | * Get current widget name with optional custom widget namespace. |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | public function getWidgetNameWithCustomNamespace() |
||
231 | } |
||
232 |