@@ -350,8 +350,7 @@ discard block |
||
350 | 350 | if(($sFinalFile) && is_file($sJsAppDir . $sFinalFile . $sExtension)) |
351 | 351 | { |
352 | 352 | $sOutFile = $sFinalFile . $sExtension; |
353 | - } |
|
354 | - else |
|
353 | + } else |
|
355 | 354 | { |
356 | 355 | // The plugins scripts are written into the javascript app dir |
357 | 356 | $sHash = $this->generateHash(); |
@@ -366,8 +365,7 @@ discard block |
||
366 | 365 | if(is_file($sJsAppDir . $sMinFile)) |
367 | 366 | { |
368 | 367 | $sOutFile = $sMinFile; // The file was already minified |
369 | - } |
|
370 | - elseif(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
368 | + } elseif(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
371 | 369 | { |
372 | 370 | $sOutFile = $sMinFile; |
373 | 371 | } |
@@ -387,8 +385,7 @@ discard block |
||
387 | 385 | 'sJsOptions' => $this->getOption('js.app.options', ''), |
388 | 386 | 'sUrl' => $sJsAppURI . $sOutFile, |
389 | 387 | ]); |
390 | - } |
|
391 | - else |
|
388 | + } else |
|
392 | 389 | { |
393 | 390 | // The plugins scripts are wrapped with javascript tags |
394 | 391 | $sScript .= $this->xTemplate->render('jaxon::plugins/wrapper.js', [ |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | private function getJsLibExt() |
103 | 103 | { |
104 | - if(($this->getOption('js.app.minify'))) |
|
104 | + if (($this->getOption('js.app.minify'))) |
|
105 | 105 | { |
106 | 106 | return '.min.js'; |
107 | 107 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | // Check config options |
119 | 119 | // - The js.app.export option must be set to true |
120 | 120 | // - The js.app.uri and js.app.dir options must be set to non null values |
121 | - if(!$this->getOption('js.app.export') || |
|
121 | + if (!$this->getOption('js.app.export') || |
|
122 | 122 | !$this->getOption('js.app.uri') || |
123 | 123 | !$this->getOption('js.app.dir')) |
124 | 124 | { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | // Check dir access |
128 | 128 | // - The js.app.dir must be writable |
129 | 129 | $sJsAppDir = $this->getOption('js.app.dir'); |
130 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
130 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
131 | 131 | { |
132 | 132 | return false; |
133 | 133 | } |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | private function generateHash() |
143 | 143 | { |
144 | 144 | $sHash = jaxon()->getVersion(); |
145 | - foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
145 | + foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
146 | 146 | { |
147 | 147 | $sHash .= $xPlugin->generateHash(); |
148 | 148 | } |
149 | - foreach($this->xPluginManager->getResponsePlugins() as $xPlugin) |
|
149 | + foreach ($this->xPluginManager->getResponsePlugins() as $xPlugin) |
|
150 | 150 | { |
151 | 151 | $sHash .= $xPlugin->generateHash(); |
152 | 152 | } |
@@ -160,25 +160,25 @@ discard block |
||
160 | 160 | */ |
161 | 161 | private function makePluginsCode() |
162 | 162 | { |
163 | - if($this->sCssCode === null || $this->sJsCode === null || $this->sJsScript === null) |
|
163 | + if ($this->sCssCode === null || $this->sJsCode === null || $this->sJsScript === null) |
|
164 | 164 | { |
165 | 165 | $this->sCssCode = ''; |
166 | 166 | $this->sJsCode = ''; |
167 | 167 | $this->sJsScript = ''; |
168 | - foreach($this->xPluginManager->getPlugins() as $xPlugin) |
|
168 | + foreach ($this->xPluginManager->getPlugins() as $xPlugin) |
|
169 | 169 | { |
170 | - if($xPlugin instanceof Response) |
|
170 | + if ($xPlugin instanceof Response) |
|
171 | 171 | { |
172 | - if(($sCssCode = trim($xPlugin->getCss()))) |
|
172 | + if (($sCssCode = trim($xPlugin->getCss()))) |
|
173 | 173 | { |
174 | 174 | $this->sCssCode .= rtrim($sCssCode, " \n") . "\n"; |
175 | 175 | } |
176 | - if(($sJsCode = trim($xPlugin->getJs()))) |
|
176 | + if (($sJsCode = trim($xPlugin->getJs()))) |
|
177 | 177 | { |
178 | 178 | $this->sJsCode .= rtrim($sJsCode, " \n") . "\n"; |
179 | 179 | } |
180 | 180 | } |
181 | - if(($sJsScript = trim($xPlugin->getScript()))) |
|
181 | + if (($sJsScript = trim($xPlugin->getScript()))) |
|
182 | 182 | { |
183 | 183 | $this->sJsScript .= trim($sJsScript, " \n") . "\n"; |
184 | 184 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | // Add component files to the javascript file array; |
221 | 221 | $aJsFiles = [$sJsCoreUrl]; |
222 | - if($this->getOption('core.debug.on')) |
|
222 | + if ($this->getOption('core.debug.on')) |
|
223 | 223 | { |
224 | 224 | $aJsFiles[] = $sJsDebugUrl; |
225 | 225 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
319 | 319 | { |
320 | - if(!$this->getOption('core.request.uri')) |
|
320 | + if (!$this->getOption('core.request.uri')) |
|
321 | 321 | { |
322 | 322 | $this->setOption('core.request.uri', URI::detect()); |
323 | 323 | } |
@@ -326,16 +326,16 @@ discard block |
||
326 | 326 | $this->makePluginsCode(); |
327 | 327 | |
328 | 328 | $sScript = ''; |
329 | - if(($bIncludeCss)) |
|
329 | + if (($bIncludeCss)) |
|
330 | 330 | { |
331 | 331 | $sScript .= $this->getCss() . "\n"; |
332 | 332 | } |
333 | - if(($bIncludeJs)) |
|
333 | + if (($bIncludeJs)) |
|
334 | 334 | { |
335 | 335 | $sScript .= $this->getJs() . "\n"; |
336 | 336 | } |
337 | 337 | |
338 | - if($this->canExportJavascript()) |
|
338 | + if ($this->canExportJavascript()) |
|
339 | 339 | { |
340 | 340 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
341 | 341 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $sExtension = $this->getJsLibExt(); |
344 | 344 | |
345 | 345 | // Check if the final file already exists |
346 | - if(($sFinalFile) && is_file($sJsAppDir . $sFinalFile . $sExtension)) |
|
346 | + if (($sFinalFile) && is_file($sJsAppDir . $sFinalFile . $sExtension)) |
|
347 | 347 | { |
348 | 348 | $sOutFile = $sFinalFile . $sExtension; |
349 | 349 | } |
@@ -353,25 +353,25 @@ discard block |
||
353 | 353 | $sHash = $this->generateHash(); |
354 | 354 | $sOutFile = $sHash . '.js'; |
355 | 355 | $sMinFile = $sHash . '.min.js'; |
356 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
356 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
357 | 357 | { |
358 | 358 | file_put_contents($sJsAppDir . $sOutFile, $this->_getScript()); |
359 | 359 | } |
360 | - if(($this->getOption('js.app.minify'))) |
|
360 | + if (($this->getOption('js.app.minify'))) |
|
361 | 361 | { |
362 | - if(is_file($sJsAppDir . $sMinFile)) |
|
362 | + if (is_file($sJsAppDir . $sMinFile)) |
|
363 | 363 | { |
364 | 364 | $sOutFile = $sMinFile; // The file was already minified |
365 | 365 | } |
366 | - elseif(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
366 | + elseif (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
367 | 367 | { |
368 | 368 | $sOutFile = $sMinFile; |
369 | 369 | } |
370 | 370 | } |
371 | 371 | // Copy the file to its final location |
372 | - if(($sFinalFile)) |
|
372 | + if (($sFinalFile)) |
|
373 | 373 | { |
374 | - if(copy($sJsAppDir . $sOutFile, $sJsAppDir . $sFinalFile . $sExtension)) |
|
374 | + if (copy($sJsAppDir . $sOutFile, $sJsAppDir . $sFinalFile . $sExtension)) |
|
375 | 375 | { |
376 | 376 | $sOutFile = $sFinalFile . $sExtension; |
377 | 377 | } |
@@ -138,33 +138,33 @@ discard block |
||
138 | 138 | $bIsAlert = ($xPlugin instanceof \Jaxon\Contracts\Dialogs\Alert); |
139 | 139 | $bIsConfirm = ($xPlugin instanceof \Jaxon\Contracts\Dialogs\Confirm); |
140 | 140 | $bIsListener = ($xPlugin instanceof \Jaxon\Contracts\Event\Listener); |
141 | - if($xPlugin instanceof Request) |
|
141 | + if ($xPlugin instanceof Request) |
|
142 | 142 | { |
143 | 143 | // The name of a request plugin is used as key in the plugin table |
144 | 144 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
145 | 145 | } |
146 | - elseif($xPlugin instanceof Response) |
|
146 | + elseif ($xPlugin instanceof Response) |
|
147 | 147 | { |
148 | 148 | // The name of a response plugin is used as key in the plugin table |
149 | 149 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
150 | 150 | } |
151 | - elseif(!$bIsConfirm && !$bIsAlert && !$bIsListener) |
|
151 | + elseif (!$bIsConfirm && !$bIsAlert && !$bIsListener) |
|
152 | 152 | { |
153 | 153 | $sErrorMessage = $this->trans('errors.register.invalid', ['name' => get_class($xPlugin)]); |
154 | 154 | throw new \Jaxon\Exception\Error($sErrorMessage); |
155 | 155 | } |
156 | 156 | // This plugin implements the Alert interface |
157 | - if($bIsAlert) |
|
157 | + if ($bIsAlert) |
|
158 | 158 | { |
159 | 159 | jaxon()->dialog()->setAlert($xPlugin); |
160 | 160 | } |
161 | 161 | // This plugin implements the Confirm interface |
162 | - if($bIsConfirm) |
|
162 | + if ($bIsConfirm) |
|
163 | 163 | { |
164 | 164 | jaxon()->dialog()->setConfirm($xPlugin); |
165 | 165 | } |
166 | 166 | // Register the plugin as an event listener |
167 | - if($bIsListener) |
|
167 | + if ($bIsListener) |
|
168 | 168 | { |
169 | 169 | $this->addEventListener($xPlugin); |
170 | 170 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function registerCallable($sType, $sCallable, $aOptions = []) |
201 | 201 | { |
202 | - if(!key_exists($sType, $this->aRequestPlugins)) |
|
202 | + if (!key_exists($sType, $this->aRequestPlugins)) |
|
203 | 203 | { |
204 | 204 | throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType])); |
205 | 205 | } |
@@ -220,14 +220,14 @@ discard block |
||
220 | 220 | private function registerCallablesFromConfig($xAppConfig, $sSection, $sCallableType) |
221 | 221 | { |
222 | 222 | $aConfig = $xAppConfig->getOption($sSection, []); |
223 | - foreach($aConfig as $xKey => $xValue) |
|
223 | + foreach ($aConfig as $xKey => $xValue) |
|
224 | 224 | { |
225 | - if(is_integer($xKey) && is_string($xValue)) |
|
225 | + if (is_integer($xKey) && is_string($xValue)) |
|
226 | 226 | { |
227 | 227 | // Register a function without options |
228 | 228 | $this->registerCallable($sCallableType, $xValue); |
229 | 229 | } |
230 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
230 | + elseif (is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
231 | 231 | { |
232 | 232 | // Register a function with options |
233 | 233 | $this->registerCallable($sCallableType, $xKey, $xValue); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | public function getResponsePlugin($sName) |
271 | 271 | { |
272 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
272 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
273 | 273 | { |
274 | 274 | return $this->aResponsePlugins[$sName]; |
275 | 275 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public function getRequestPlugin($sName) |
287 | 287 | { |
288 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
288 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
289 | 289 | { |
290 | 290 | return $this->aRequestPlugins[$sName]; |
291 | 291 | } |
@@ -142,13 +142,11 @@ discard block |
||
142 | 142 | { |
143 | 143 | // The name of a request plugin is used as key in the plugin table |
144 | 144 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
145 | - } |
|
146 | - elseif($xPlugin instanceof Response) |
|
145 | + } elseif($xPlugin instanceof Response) |
|
147 | 146 | { |
148 | 147 | // The name of a response plugin is used as key in the plugin table |
149 | 148 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
150 | - } |
|
151 | - elseif(!$bIsConfirm && !$bIsAlert && !$bIsListener) |
|
149 | + } elseif(!$bIsConfirm && !$bIsAlert && !$bIsListener) |
|
152 | 150 | { |
153 | 151 | $sErrorMessage = $this->trans('errors.register.invalid', ['name' => get_class($xPlugin)]); |
154 | 152 | throw new \Jaxon\Exception\Error($sErrorMessage); |
@@ -226,13 +224,11 @@ discard block |
||
226 | 224 | { |
227 | 225 | // Register a function without options |
228 | 226 | $this->registerCallable($sCallableType, $xValue); |
229 | - } |
|
230 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
227 | + } elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
231 | 228 | { |
232 | 229 | // Register a function with options |
233 | 230 | $this->registerCallable($sCallableType, $xKey, $xValue); |
234 | - } |
|
235 | - else |
|
231 | + } else |
|
236 | 232 | { |
237 | 233 | continue; |
238 | 234 | // Todo: throw an exception |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $this->triggerEvent('pre.setup'); |
155 | 155 | |
156 | 156 | // Add the view renderer |
157 | - $view->addRenderer('jaxon', function () { |
|
157 | + $view->addRenderer('jaxon', function() { |
|
158 | 158 | return new View\View(); |
159 | 159 | }); |
160 | 160 | |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | // Use the Composer autoloader. It's important to call this before triggers and callbacks. |
182 | 182 | // $jaxon->useComposerAutoloader(); |
183 | 183 | // Jaxon library settings |
184 | - if(!$jaxon->hasOption('js.app.export')) |
|
184 | + if (!$jaxon->hasOption('js.app.export')) |
|
185 | 185 | { |
186 | 186 | $jaxon->setOption('js.app.export', $this->bExportJs); |
187 | 187 | } |
188 | - if(!$jaxon->hasOption('js.app.minify')) |
|
188 | + if (!$jaxon->hasOption('js.app.minify')) |
|
189 | 189 | { |
190 | 190 | $jaxon->setOption('js.app.minify', $this->bMinifyJs); |
191 | 191 | } |
192 | - if(!$jaxon->hasOption('js.app.uri') && $this->sJsUri != '') |
|
192 | + if (!$jaxon->hasOption('js.app.uri') && $this->sJsUri != '') |
|
193 | 193 | { |
194 | 194 | $jaxon->setOption('js.app.uri', $this->sJsUri); |
195 | 195 | } |
196 | - if(!$jaxon->hasOption('js.app.dir') && $this->sJsDir != '') |
|
196 | + if (!$jaxon->hasOption('js.app.dir') && $this->sJsDir != '') |
|
197 | 197 | { |
198 | 198 | $jaxon->setOption('js.app.dir', $this->sJsDir); |
199 | 199 | } |
200 | 200 | // Set the request URI |
201 | - if(!$jaxon->hasOption('core.request.uri') && $this->sUri != '') |
|
201 | + if (!$jaxon->hasOption('core.request.uri') && $this->sUri != '') |
|
202 | 202 | { |
203 | 203 | $jaxon->setOption('core.request.uri', $this->sUri); |
204 | 204 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | return jaxon()->instance($name); |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
97 | + /** |
|
98 | 98 | * Get the uploaded files |
99 | 99 | * |
100 | 100 | * @return array |
@@ -81,12 +81,12 @@ |
||
81 | 81 | $xCallableObject = jaxon()->di()->getCallableRepository()->getCallableObject(get_class($this)); |
82 | 82 | $cFirstChar = substr($name, 0, 1); |
83 | 83 | // If the class name starts with a dot, then find the class in the same full namespace as the caller |
84 | - if($cFirstChar == ':') |
|
84 | + if ($cFirstChar == ':') |
|
85 | 85 | { |
86 | 86 | $name = $xCallableObject->getRootNamespace() . '\\' . str_replace('.', '\\', substr($name, 1)); |
87 | 87 | } |
88 | 88 | // If the class name starts with a dot, then find the class in the same base namespace as the caller |
89 | - elseif($cFirstChar == '.') |
|
89 | + elseif ($cFirstChar == '.') |
|
90 | 90 | { |
91 | 91 | $name = $xCallableObject->getNamespace() . '\\' . str_replace('.', '\\', substr($name, 1)); |
92 | 92 | } |
@@ -105,19 +105,19 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public static function make($xValue) |
107 | 107 | { |
108 | - if($xValue instanceof Contracts\Parameter) |
|
108 | + if ($xValue instanceof Contracts\Parameter) |
|
109 | 109 | { |
110 | 110 | return $xValue; |
111 | 111 | } |
112 | - elseif(is_numeric($xValue)) |
|
112 | + elseif (is_numeric($xValue)) |
|
113 | 113 | { |
114 | 114 | return new Parameter(self::NUMERIC_VALUE, $xValue); |
115 | 115 | } |
116 | - elseif(is_string($xValue)) |
|
116 | + elseif (is_string($xValue)) |
|
117 | 117 | { |
118 | 118 | return new Parameter(self::QUOTED_VALUE, $xValue); |
119 | 119 | } |
120 | - elseif(is_bool($xValue)) |
|
120 | + elseif (is_bool($xValue)) |
|
121 | 121 | { |
122 | 122 | return new Parameter(self::BOOL_VALUE, $xValue); |
123 | 123 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function getScript() |
162 | 162 | { |
163 | 163 | $sJsCode = ''; |
164 | - switch($this->sType) |
|
164 | + switch ($this->sType) |
|
165 | 165 | { |
166 | 166 | case self::FORM_VALUES: |
167 | 167 | $sJsCode = $this->getJsCall('getFormValues', $this->xValue); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $sJsCode = (string)$this->xValue; |
189 | 189 | break; |
190 | 190 | case self::JS_VALUE: |
191 | - if(is_array($this->xValue) || is_object($this->xValue)) |
|
191 | + if (is_array($this->xValue) || is_object($this->xValue)) |
|
192 | 192 | { |
193 | 193 | // Unable to use double quotes here because they cannot be handled on client side. |
194 | 194 | // So we are using simple quotes even if the Json standard recommends double quotes. |
@@ -108,20 +108,16 @@ discard block |
||
108 | 108 | if($xValue instanceof Contracts\Parameter) |
109 | 109 | { |
110 | 110 | return $xValue; |
111 | - } |
|
112 | - elseif(is_numeric($xValue)) |
|
111 | + } elseif(is_numeric($xValue)) |
|
113 | 112 | { |
114 | 113 | return new Parameter(self::NUMERIC_VALUE, $xValue); |
115 | - } |
|
116 | - elseif(is_string($xValue)) |
|
114 | + } elseif(is_string($xValue)) |
|
117 | 115 | { |
118 | 116 | return new Parameter(self::QUOTED_VALUE, $xValue); |
119 | - } |
|
120 | - elseif(is_bool($xValue)) |
|
117 | + } elseif(is_bool($xValue)) |
|
121 | 118 | { |
122 | 119 | return new Parameter(self::BOOL_VALUE, $xValue); |
123 | - } |
|
124 | - else // if(is_array($xValue) || is_object($xValue)) |
|
120 | + } else // if(is_array($xValue) || is_object($xValue)) |
|
125 | 121 | { |
126 | 122 | return new Parameter(self::JS_VALUE, $xValue); |
127 | 123 | } |
@@ -193,8 +189,7 @@ discard block |
||
193 | 189 | // Unable to use double quotes here because they cannot be handled on client side. |
194 | 190 | // So we are using simple quotes even if the Json standard recommends double quotes. |
195 | 191 | $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT)); |
196 | - } |
|
197 | - else |
|
192 | + } else |
|
198 | 193 | { |
199 | 194 | $sJsCode = (string)$this->xValue; |
200 | 195 | } |
@@ -154,9 +154,9 @@ |
||
154 | 154 | */ |
155 | 155 | public function addParameters(array $aParameters) |
156 | 156 | { |
157 | - foreach($aParameters as $xParameter) |
|
157 | + foreach ($aParameters as $xParameter) |
|
158 | 158 | { |
159 | - if($xParameter instanceof JsCall) |
|
159 | + if ($xParameter instanceof JsCall) |
|
160 | 160 | { |
161 | 161 | $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
162 | 162 | } |
@@ -159,8 +159,7 @@ |
||
159 | 159 | if($xParameter instanceof JsCall) |
160 | 160 | { |
161 | 161 | $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); |
162 | - } |
|
163 | - else |
|
162 | + } else |
|
164 | 163 | { |
165 | 164 | $this->pushParameter(Parameter::make($xParameter)); |
166 | 165 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function configure($sName, $sValue) |
86 | 86 | { |
87 | - switch($sName) |
|
87 | + switch ($sName) |
|
88 | 88 | { |
89 | 89 | case 'class': // The user function is a method in the given class |
90 | 90 | $this->xCallableFunction = [$sValue, $this->xCallableFunction]; |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function call($aArgs = []) |
141 | 141 | { |
142 | - if(($this->sInclude)) |
|
142 | + if (($this->sInclude)) |
|
143 | 143 | { |
144 | 144 | require_once $this->sInclude; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // If the function is an alias for a class method, then instanciate the class |
148 | - if(is_array($this->xCallableFunction) && is_string($this->xCallableFunction[0])) |
|
148 | + if (is_array($this->xCallableFunction) && is_string($this->xCallableFunction[0])) |
|
149 | 149 | { |
150 | 150 | $sClassName = $this->xCallableFunction[0]; |
151 | 151 | $this->xCallableFunction[0] = new $sClassName; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | // Set the composer autoloader |
86 | 86 | $sAutoloadFile = __DIR__ . '/../../../../../autoload.php'; |
87 | - if(file_exists($sAutoloadFile)) |
|
87 | + if (file_exists($sAutoloadFile)) |
|
88 | 88 | { |
89 | 89 | $this->xAutoloader = require($sAutoloadFile); |
90 | 90 | } |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | private function getClassOptions($sClassName, array $aDirectoryOptions, array $aDefaultOptions = []) |
116 | 116 | { |
117 | 117 | $aOptions = $aDefaultOptions; |
118 | - if(key_exists('separator', $aDirectoryOptions)) |
|
118 | + if (key_exists('separator', $aDirectoryOptions)) |
|
119 | 119 | { |
120 | 120 | $aOptions['separator'] = $aDirectoryOptions['separator']; |
121 | 121 | } |
122 | - if(key_exists('protected', $aDirectoryOptions)) |
|
122 | + if (key_exists('protected', $aDirectoryOptions)) |
|
123 | 123 | { |
124 | 124 | $aOptions['protected'] = $aDirectoryOptions['protected']; |
125 | 125 | } |
126 | - if(key_exists('*', $aDirectoryOptions)) |
|
126 | + if (key_exists('*', $aDirectoryOptions)) |
|
127 | 127 | { |
128 | 128 | $aOptions = array_merge($aOptions, $aDirectoryOptions['*']); |
129 | 129 | } |
130 | - if(key_exists($sClassName, $aDirectoryOptions)) |
|
130 | + if (key_exists($sClassName, $aDirectoryOptions)) |
|
131 | 131 | { |
132 | 132 | $aOptions = array_merge($aOptions, $aDirectoryOptions[$sClassName]); |
133 | 133 | } |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
148 | 148 | $itFile = new RecursiveIteratorIterator($itDir); |
149 | 149 | // Iterate on dir content |
150 | - foreach($itFile as $xFile) |
|
150 | + foreach ($itFile as $xFile) |
|
151 | 151 | { |
152 | 152 | // skip everything except PHP files |
153 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
153 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
154 | 154 | { |
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $aClassOptions = []; |
159 | 159 | // No more classmap autoloading. The file will be included when needed. |
160 | - if(($aOptions['autoload'])) |
|
160 | + if (($aOptions['autoload'])) |
|
161 | 161 | { |
162 | 162 | $aClassOptions['include'] = $xFile->getPathname(); |
163 | 163 | } |
@@ -178,26 +178,26 @@ discard block |
||
178 | 178 | public function addNamespace($sNamespace, array $aOptions) |
179 | 179 | { |
180 | 180 | // Separator default value |
181 | - if(!key_exists('separator', $aOptions)) |
|
181 | + if (!key_exists('separator', $aOptions)) |
|
182 | 182 | { |
183 | 183 | $aOptions['separator'] = '.'; |
184 | 184 | } |
185 | 185 | $aOptions['separator'] = trim($aOptions['separator']); |
186 | - if(!in_array($aOptions['separator'], ['.', '_'])) |
|
186 | + if (!in_array($aOptions['separator'], ['.', '_'])) |
|
187 | 187 | { |
188 | 188 | $aOptions['separator'] = '.'; |
189 | 189 | } |
190 | - if($aOptions['separator'] == '_') |
|
190 | + if ($aOptions['separator'] == '_') |
|
191 | 191 | { |
192 | 192 | $this->bUsingUnderscore = true; |
193 | 193 | } |
194 | 194 | // Set the autoload option default value |
195 | - if(!key_exists('autoload', $aOptions)) |
|
195 | + if (!key_exists('autoload', $aOptions)) |
|
196 | 196 | { |
197 | 197 | $aOptions['autoload'] = true; |
198 | 198 | } |
199 | 199 | // Register the dir with PSR4 autoloading |
200 | - if(($aOptions['autoload']) && $this->xAutoloader != null) |
|
200 | + if (($aOptions['autoload']) && $this->xAutoloader != null) |
|
201 | 201 | { |
202 | 202 | $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']); |
203 | 203 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | private function getOptionsFromClass($sClassName) |
216 | 216 | { |
217 | - if(!key_exists($sClassName, $this->aClassOptions)) |
|
217 | + if (!key_exists($sClassName, $this->aClassOptions)) |
|
218 | 218 | { |
219 | 219 | return null; // Class not registered |
220 | 220 | } |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | private function getOptionsFromNamespace($sClassName, $sNamespace = null) |
233 | 233 | { |
234 | 234 | // Find the corresponding namespace |
235 | - if($sNamespace === null) |
|
235 | + if ($sNamespace === null) |
|
236 | 236 | { |
237 | - foreach(array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
237 | + foreach (array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
238 | 238 | { |
239 | - if(substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
239 | + if (substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
240 | 240 | { |
241 | 241 | $sNamespace = $_sNamespace; |
242 | 242 | break; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
246 | - if($sNamespace === null) |
|
246 | + if ($sNamespace === null) |
|
247 | 247 | { |
248 | 248 | return null; // Class not registered |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | // Get the class options |
252 | 252 | $aOptions = $this->aNamespaceOptions[$sNamespace]; |
253 | 253 | $aDefaultOptions = ['namespace' => $sNamespace]; |
254 | - if(key_exists('separator', $aOptions)) |
|
254 | + if (key_exists('separator', $aOptions)) |
|
255 | 255 | { |
256 | 256 | $aDefaultOptions['separator'] = $aOptions['separator']; |
257 | 257 | } |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | protected function _getCallableObject($sClassName, array $aOptions) |
270 | 270 | { |
271 | 271 | // Make sure the registered class exists |
272 | - if(key_exists('include', $aOptions)) |
|
272 | + if (key_exists('include', $aOptions)) |
|
273 | 273 | { |
274 | 274 | require_once($aOptions['include']); |
275 | 275 | } |
276 | - if(!class_exists($sClassName)) |
|
276 | + if (!class_exists($sClassName)) |
|
277 | 277 | { |
278 | 278 | return null; |
279 | 279 | } |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | // Create the callable object |
282 | 282 | $xCallableObject = new CallableObject($sClassName); |
283 | 283 | $this->aCallableOptions[$sClassName] = []; |
284 | - foreach($aOptions as $sName => $xValue) |
|
284 | + foreach ($aOptions as $sName => $xValue) |
|
285 | 285 | { |
286 | - if(in_array($sName, ['separator', 'namespace', 'protected'])) |
|
286 | + if (in_array($sName, ['separator', 'namespace', 'protected'])) |
|
287 | 287 | { |
288 | 288 | $xCallableObject->configure($sName, $xValue); |
289 | 289 | } |
290 | - elseif(is_array($xValue) && $sName != 'include') |
|
290 | + elseif (is_array($xValue) && $sName != 'include') |
|
291 | 291 | { |
292 | 292 | // These options are to be included in javascript code. |
293 | 293 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -324,22 +324,22 @@ discard block |
||
324 | 324 | // at the beginning and the end of the class name. |
325 | 325 | $sClassName = (string)$sClassName; |
326 | 326 | $sClassName = trim(str_replace('.', '\\', $sClassName), '\\'); |
327 | - if($this->bUsingUnderscore) |
|
327 | + if ($this->bUsingUnderscore) |
|
328 | 328 | { |
329 | 329 | $sClassName = trim(str_replace('_', '\\', $sClassName), '\\'); |
330 | 330 | } |
331 | 331 | |
332 | - if(key_exists($sClassName, $this->aCallableObjects)) |
|
332 | + if (key_exists($sClassName, $this->aCallableObjects)) |
|
333 | 333 | { |
334 | 334 | return $this->aCallableObjects[$sClassName]; |
335 | 335 | } |
336 | 336 | |
337 | 337 | $aOptions = $this->getOptionsFromClass($sClassName); |
338 | - if($aOptions === null) |
|
338 | + if ($aOptions === null) |
|
339 | 339 | { |
340 | 340 | $aOptions = $this->getOptionsFromNamespace($sClassName); |
341 | 341 | } |
342 | - if($aOptions === null) |
|
342 | + if ($aOptions === null) |
|
343 | 343 | { |
344 | 344 | return null; |
345 | 345 | } |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | public function createCallableObjects() |
356 | 356 | { |
357 | 357 | // Create callable objects for registered classes |
358 | - foreach($this->aClassOptions as $sClassName => $aClassOptions) |
|
358 | + foreach ($this->aClassOptions as $sClassName => $aClassOptions) |
|
359 | 359 | { |
360 | - if(!key_exists($sClassName, $this->aCallableObjects)) |
|
360 | + if (!key_exists($sClassName, $this->aCallableObjects)) |
|
361 | 361 | { |
362 | 362 | $this->_getCallableObject($sClassName, $aClassOptions); |
363 | 363 | } |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | |
366 | 366 | // Create callable objects for registered namespaces |
367 | 367 | $sDS = DIRECTORY_SEPARATOR; |
368 | - foreach($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
368 | + foreach ($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
369 | 369 | { |
370 | - if(key_exists($sNamespace, $this->aNamespaces)) |
|
370 | + if (key_exists($sNamespace, $this->aNamespaces)) |
|
371 | 371 | { |
372 | 372 | continue; |
373 | 373 | } |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | $sDirectory = $aOptions['directory']; |
379 | 379 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
380 | 380 | $itFile = new RecursiveIteratorIterator($itDir); |
381 | - foreach($itFile as $xFile) |
|
381 | + foreach ($itFile as $xFile) |
|
382 | 382 | { |
383 | 383 | // skip everything except PHP files |
384 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
384 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
385 | 385 | { |
386 | 386 | continue; |
387 | 387 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | $sClassPath = $sNamespace; |
391 | 391 | $sRelativePath = substr($xFile->getPath(), strlen($sDirectory)); |
392 | 392 | $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\'); |
393 | - if($sRelativePath != '') |
|
393 | + if ($sRelativePath != '') |
|
394 | 394 | { |
395 | 395 | $sClassPath .= '\\' . $sRelativePath; |
396 | 396 | } |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | $this->aNamespaces[$sClassPath] = ['separator' => $aOptions['separator']]; |
399 | 399 | $sClassName = $sClassPath . '\\' . $xFile->getBasename('.php'); |
400 | 400 | |
401 | - if(!key_exists($sClassName, $this->aCallableObjects)) |
|
401 | + if (!key_exists($sClassName, $this->aCallableObjects)) |
|
402 | 402 | { |
403 | 403 | $aClassOptions = $this->getOptionsFromNamespace($sClassName, $sNamespace); |
404 | - if($aClassOptions !== null) |
|
404 | + if ($aClassOptions !== null) |
|
405 | 405 | { |
406 | 406 | $this->_getCallableObject($sClassName, $aClassOptions); |
407 | 407 | } |
@@ -286,8 +286,7 @@ |
||
286 | 286 | if(in_array($sName, ['separator', 'namespace', 'protected'])) |
287 | 287 | { |
288 | 288 | $xCallableObject->configure($sName, $xValue); |
289 | - } |
|
290 | - elseif(is_array($xValue) && $sName != 'include') |
|
289 | + } elseif(is_array($xValue) && $sName != 'include') |
|
291 | 290 | { |
292 | 291 | // These options are to be included in javascript code. |
293 | 292 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -159,8 +159,7 @@ discard block |
||
159 | 159 | if(is_array($sValue)) |
160 | 160 | { |
161 | 161 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
162 | - } |
|
163 | - elseif(is_string($sValue)) |
|
162 | + } elseif(is_string($sValue)) |
|
164 | 163 | { |
165 | 164 | $this->aProtectedMethods[] = $sValue; |
166 | 165 | } |
@@ -217,8 +216,7 @@ discard block |
||
217 | 216 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
218 | 217 | } |
219 | 218 | $this->xRegisteredObject = $this->xReflectionClass->newInstanceArgs($parameterInstances); |
220 | - } |
|
221 | - else |
|
219 | + } else |
|
222 | 220 | { |
223 | 221 | $this->xRegisteredObject = $this->xReflectionClass->newInstance(); |
224 | 222 | } |
@@ -138,29 +138,29 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function configure($sName, $sValue) |
140 | 140 | { |
141 | - switch($sName) |
|
141 | + switch ($sName) |
|
142 | 142 | { |
143 | 143 | // Set the separator |
144 | 144 | case 'separator': |
145 | - if($sValue == '_' || $sValue == '.') |
|
145 | + if ($sValue == '_' || $sValue == '.') |
|
146 | 146 | { |
147 | 147 | $this->sSeparator = $sValue; |
148 | 148 | } |
149 | 149 | break; |
150 | 150 | // Set the namespace |
151 | 151 | case 'namespace': |
152 | - if(is_string($sValue)) |
|
152 | + if (is_string($sValue)) |
|
153 | 153 | { |
154 | 154 | $this->sNamespace = $sValue; |
155 | 155 | } |
156 | 156 | break; |
157 | 157 | // Set the protected methods |
158 | 158 | case 'protected': |
159 | - if(is_array($sValue)) |
|
159 | + if (is_array($sValue)) |
|
160 | 160 | { |
161 | 161 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
162 | 162 | } |
163 | - elseif(is_string($sValue)) |
|
163 | + elseif (is_string($sValue)) |
|
164 | 164 | { |
165 | 165 | $this->aProtectedMethods[] = $sValue; |
166 | 166 | } |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | public function getMethods() |
179 | 179 | { |
180 | 180 | $aMethods = []; |
181 | - foreach($this->xReflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
181 | + foreach ($this->xReflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
182 | 182 | { |
183 | 183 | $sMethodName = $xMethod->getShortName(); |
184 | 184 | // Don't take magic __call, __construct, __destruct methods |
185 | - if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
185 | + if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
186 | 186 | { |
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | // Don't take excluded methods |
190 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
190 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
191 | 191 | { |
192 | 192 | continue; |
193 | 193 | } |
@@ -203,15 +203,15 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function getRegisteredObject() |
205 | 205 | { |
206 | - if($this->xRegisteredObject == null) |
|
206 | + if ($this->xRegisteredObject == null) |
|
207 | 207 | { |
208 | 208 | $di = jaxon()->di(); |
209 | 209 | // Use the Reflection class to get the parameters of the constructor |
210 | - if(($constructor = $this->xReflectionClass->getConstructor()) != null) |
|
210 | + if (($constructor = $this->xReflectionClass->getConstructor()) != null) |
|
211 | 211 | { |
212 | 212 | $parameters = $constructor->getParameters(); |
213 | 213 | $parameterInstances = []; |
214 | - foreach($parameters as $parameter) |
|
214 | + foreach ($parameters as $parameter) |
|
215 | 215 | { |
216 | 216 | // Get the parameter instance from the DI |
217 | 217 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | // Initialize the object |
227 | - if($this->xRegisteredObject instanceof \Jaxon\CallableClass) |
|
227 | + if ($this->xRegisteredObject instanceof \Jaxon\CallableClass) |
|
228 | 228 | { |
229 | 229 | $this->xRegisteredObject->response = jaxon()->getResponse(); |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Run the callback for class initialisation |
233 | - if(($xCallback = $di->getRequestHandler()->getCallbackManager()->init())) |
|
233 | + if (($xCallback = $di->getRequestHandler()->getCallbackManager()->init())) |
|
234 | 234 | { |
235 | 235 | call_user_func_array($xCallback, [$this->xRegisteredObject]); |
236 | 236 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function call($sMethod, $aArgs) |
262 | 262 | { |
263 | - if(!$this->hasMethod($sMethod)) |
|
263 | + if (!$this->hasMethod($sMethod)) |
|
264 | 264 | { |
265 | 265 | return; |
266 | 266 | } |