@@ -120,22 +120,22 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function configure($sName, $sValue) |
| 122 | 122 | { |
| 123 | - switch($sName) |
|
| 123 | + switch ($sName) |
|
| 124 | 124 | { |
| 125 | 125 | // Set the separator |
| 126 | 126 | case 'separator'; |
| 127 | - if($sValue == '_' || $sValue == '.') |
|
| 127 | + if ($sValue == '_' || $sValue == '.') |
|
| 128 | 128 | { |
| 129 | 129 | $this->separator = $sValue; |
| 130 | 130 | } |
| 131 | 131 | break; |
| 132 | 132 | // Set the protected methods |
| 133 | 133 | case 'protected': |
| 134 | - if(is_array($sValue)) |
|
| 134 | + if (is_array($sValue)) |
|
| 135 | 135 | { |
| 136 | 136 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
| 137 | 137 | } |
| 138 | - elseif(is_string($sValue)) |
|
| 138 | + elseif (is_string($sValue)) |
|
| 139 | 139 | { |
| 140 | 140 | $this->aProtectedMethods[] = $sValue; |
| 141 | 141 | } |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | public function getMethods() |
| 154 | 154 | { |
| 155 | 155 | $aMethods = []; |
| 156 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 156 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 157 | 157 | { |
| 158 | 158 | $sMethodName = $xMethod->getShortName(); |
| 159 | 159 | // Don't take magic __call, __construct, __destruct methods |
| 160 | - if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 160 | + if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 161 | 161 | { |
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | // Don't take excluded methods |
| 165 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 165 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 166 | 166 | { |
| 167 | 167 | continue; |
| 168 | 168 | } |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function getRegisteredObject() |
| 180 | 180 | { |
| 181 | - if($this->registeredObject == null) |
|
| 181 | + if ($this->registeredObject == null) |
|
| 182 | 182 | { |
| 183 | 183 | $di = jaxon()->di(); |
| 184 | 184 | // Use the Reflection class to get the parameters of the constructor |
| 185 | - if(($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 185 | + if (($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 186 | 186 | { |
| 187 | 187 | $parameters = $constructor->getParameters(); |
| 188 | 188 | $parameterInstances = []; |
| 189 | - foreach($parameters as $parameter) |
|
| 189 | + foreach ($parameters as $parameter) |
|
| 190 | 190 | { |
| 191 | 191 | // Get the parameter instance from the DI |
| 192 | 192 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function call($sMethod, $aArgs) |
| 225 | 225 | { |
| 226 | - if(!$this->hasMethod($sMethod)) |
|
| 226 | + if (!$this->hasMethod($sMethod)) |
|
| 227 | 227 | { |
| 228 | 228 | return; |
| 229 | 229 | } |
| 230 | 230 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
| 231 | 231 | $registeredObject = $this->getRegisteredObject(); |
| 232 | 232 | $response = $reflectionMethod->invokeArgs($registeredObject, $aArgs); |
| 233 | - if(($response)) |
|
| 233 | + if (($response)) |
|
| 234 | 234 | { |
| 235 | 235 | $this->getResponseManager()->append($response); |
| 236 | 236 | } |
@@ -134,8 +134,7 @@ discard block |
||
| 134 | 134 | if(is_array($sValue)) |
| 135 | 135 | { |
| 136 | 136 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
| 137 | - } |
|
| 138 | - elseif(is_string($sValue)) |
|
| 137 | + } elseif(is_string($sValue)) |
|
| 139 | 138 | { |
| 140 | 139 | $this->aProtectedMethods[] = $sValue; |
| 141 | 140 | } |
@@ -192,8 +191,7 @@ discard block |
||
| 192 | 191 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
| 193 | 192 | } |
| 194 | 193 | $this->registeredObject = $this->reflectionClass->newInstanceArgs($parameterInstances); |
| 195 | - } |
|
| 196 | - else |
|
| 194 | + } else |
|
| 197 | 195 | { |
| 198 | 196 | $this->registeredObject = $this->reflectionClass->newInstance(); |
| 199 | 197 | } |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | private function getClassOptions($sClassName, array $aDirectoryOptions, array $aDefaultOptions = []) |
| 89 | 89 | { |
| 90 | 90 | $aOptions = $aDefaultOptions; |
| 91 | - if(key_exists('separator', $aDirectoryOptions)) |
|
| 91 | + if (key_exists('separator', $aDirectoryOptions)) |
|
| 92 | 92 | { |
| 93 | 93 | $aOptions['separator'] = $aDirectoryOptions['separator']; |
| 94 | 94 | } |
| 95 | - if(key_exists('protected', $aDirectoryOptions)) |
|
| 95 | + if (key_exists('protected', $aDirectoryOptions)) |
|
| 96 | 96 | { |
| 97 | 97 | $aOptions['protected'] = $aDirectoryOptions['protected']; |
| 98 | 98 | } |
| 99 | - if(key_exists('*', $aDirectoryOptions[$sNamespace])) |
|
| 99 | + if (key_exists('*', $aDirectoryOptions[$sNamespace])) |
|
| 100 | 100 | { |
| 101 | 101 | $aOptions = array_merge($aOptions, $aDirectoryOptions[$sNamespace]['*']); |
| 102 | 102 | } |
| 103 | - if(key_exists($sClassName, $aDirectoryOptions[$sNamespace])) |
|
| 103 | + if (key_exists($sClassName, $aDirectoryOptions[$sNamespace])) |
|
| 104 | 104 | { |
| 105 | 105 | $aOptions = array_merge($aOptions, $aDirectoryOptions[$sNamespace][$sClassName]); |
| 106 | 106 | } |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 121 | 121 | $itFile = new RecursiveIteratorIterator($itDir); |
| 122 | 122 | // Iterate on dir content |
| 123 | - foreach($itFile as $xFile) |
|
| 123 | + foreach ($itFile as $xFile) |
|
| 124 | 124 | { |
| 125 | 125 | // skip everything except PHP files |
| 126 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 126 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 127 | 127 | { |
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $aClassOptions = []; |
| 132 | 132 | // No more classmap autoloading. The file will be included when needed. |
| 133 | - if(($aOptions['autoload'])) |
|
| 133 | + if (($aOptions['autoload'])) |
|
| 134 | 134 | { |
| 135 | 135 | $aClassOptions['include'] = $xFile->getPathname(); |
| 136 | 136 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | private function getOptionsFromClass($sClassName) |
| 164 | 164 | { |
| 165 | - if(!key_exists($sClassName, $this->aClassOptions)) |
|
| 165 | + if (!key_exists($sClassName, $this->aClassOptions)) |
|
| 166 | 166 | { |
| 167 | 167 | return null; // Class not registered |
| 168 | 168 | } |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | // Find the corresponding namespace |
| 182 | 182 | $sNamespace = null; |
| 183 | - foreach(array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
| 183 | + foreach (array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
| 184 | 184 | { |
| 185 | - if(substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
| 185 | + if (substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
| 186 | 186 | { |
| 187 | 187 | $sNamespace = $_sNamespace; |
| 188 | 188 | break; |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | - if($sNamespace == null) |
|
| 191 | + if ($sNamespace == null) |
|
| 192 | 192 | { |
| 193 | 193 | return null; // Class not registered |
| 194 | 194 | } |
@@ -210,27 +210,27 @@ discard block |
||
| 210 | 210 | // at the beginning and the end of the class name. |
| 211 | 211 | $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\'); |
| 212 | 212 | |
| 213 | - if(key_exists($sClassName, $this->aCallableObjects)) |
|
| 213 | + if (key_exists($sClassName, $this->aCallableObjects)) |
|
| 214 | 214 | { |
| 215 | 215 | return $this->aCallableObjects[$sClassName]; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $aOptions = $this->getOptionsFromClass($sClassName); |
| 219 | - if($aOptions === null) |
|
| 219 | + if ($aOptions === null) |
|
| 220 | 220 | { |
| 221 | 221 | $aOptions = $this->getOptionsFromNamespace($sClassName); |
| 222 | 222 | } |
| 223 | - if($aOptions === null) |
|
| 223 | + if ($aOptions === null) |
|
| 224 | 224 | { |
| 225 | 225 | return null; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Make sure the registered class exists |
| 229 | - if(key_exists('include', $aOptions)) |
|
| 229 | + if (key_exists('include', $aOptions)) |
|
| 230 | 230 | { |
| 231 | 231 | require_once($aOptions['include']); |
| 232 | 232 | } |
| 233 | - if(!class_exists('\\' . $sClassName)) |
|
| 233 | + if (!class_exists('\\' . $sClassName)) |
|
| 234 | 234 | { |
| 235 | 235 | return null; |
| 236 | 236 | } |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | // Create the callable object |
| 239 | 239 | $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName); |
| 240 | 240 | $this->aCallableOptions[$sClassName] = []; |
| 241 | - foreach($aOptions as $sName => $xValue) |
|
| 241 | + foreach ($aOptions as $sName => $xValue) |
|
| 242 | 242 | { |
| 243 | - if($sName == 'separator' || $sName == 'protected') |
|
| 243 | + if ($sName == 'separator' || $sName == 'protected') |
|
| 244 | 244 | { |
| 245 | 245 | $xCallableObject->configure($sName, $xValue); |
| 246 | 246 | } |
| 247 | - elseif(is_array($xValue) && $sName != 'include') |
|
| 247 | + elseif (is_array($xValue) && $sName != 'include') |
|
| 248 | 248 | { |
| 249 | 249 | // These options are to be included in javascript code. |
| 250 | 250 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | $this->aCallableObjects[$sClassName] = $xCallableObject; |
| 254 | 254 | |
| 255 | 255 | // Register the request factory for this callable object |
| 256 | - jaxon()->di()->set($sClassName . '_Factory_Rq', function ($di) use ($sClassName) { |
|
| 256 | + jaxon()->di()->set($sClassName . '_Factory_Rq', function($di) use ($sClassName) { |
|
| 257 | 257 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 258 | 258 | return new \Jaxon\Factory\Request\Portable($xCallableObject); |
| 259 | 259 | }); |
| 260 | 260 | // Register the paginator factory for this callable object |
| 261 | - jaxon()->di()->set($sClassName . '_Factory_Pg', function ($di) use ($sClassName) { |
|
| 261 | + jaxon()->di()->set($sClassName . '_Factory_Pg', function($di) use ($sClassName) { |
|
| 262 | 262 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 263 | 263 | return new \Jaxon\Factory\Request\Paginator($xCallableObject); |
| 264 | 264 | }); |
@@ -274,16 +274,16 @@ discard block |
||
| 274 | 274 | private function createCallableObjects() |
| 275 | 275 | { |
| 276 | 276 | // Create callable objects for registered classes |
| 277 | - foreach(array_keys($this->aClassOptions) as $sClassName) |
|
| 277 | + foreach (array_keys($this->aClassOptions) as $sClassName) |
|
| 278 | 278 | { |
| 279 | 279 | $this->getCallableObject($sClassName); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Create callable objects for registered namespaces |
| 283 | 283 | $sDS = DIRECTORY_SEPARATOR; |
| 284 | - foreach($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 284 | + foreach ($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 285 | 285 | { |
| 286 | - if(key_exists($sNamespace, $this->aNamespaces)) |
|
| 286 | + if (key_exists($sNamespace, $this->aNamespaces)) |
|
| 287 | 287 | { |
| 288 | 288 | continue; |
| 289 | 289 | } |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | $sDirectory = $aOptions['directory']; |
| 295 | 295 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 296 | 296 | $itFile = new RecursiveIteratorIterator($itDir); |
| 297 | - foreach($itFile as $xFile) |
|
| 297 | + foreach ($itFile as $xFile) |
|
| 298 | 298 | { |
| 299 | 299 | // skip everything except PHP files |
| 300 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 300 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 301 | 301 | { |
| 302 | 302 | continue; |
| 303 | 303 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $sClassPath = $sNamespace; |
| 307 | 307 | $sRelativePath = substr($xFile->getPath(), strlen($sDirectory)); |
| 308 | 308 | $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\'); |
| 309 | - if($sRelativePath != '') |
|
| 309 | + if ($sRelativePath != '') |
|
| 310 | 310 | { |
| 311 | 311 | $sClassPath .= '\\' . $sRelativePath; |
| 312 | 312 | } |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | return $this->createCallableObjects(); |
| 343 | 343 | |
| 344 | 344 | $sHash = ''; |
| 345 | - foreach($this->aNamespaces as $sNamespace => $aOptions) |
|
| 345 | + foreach ($this->aNamespaces as $sNamespace => $aOptions) |
|
| 346 | 346 | { |
| 347 | 347 | $sHash .= $sNamespace . $aOptions['separator']; |
| 348 | 348 | } |
| 349 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 349 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 350 | 350 | { |
| 351 | 351 | $sHash .= $sClassName . implode('|', $xCallableObject->getMethods()); |
| 352 | 352 | } |
@@ -367,16 +367,16 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | $aJsClasses = []; |
| 369 | 369 | $sCode = ''; |
| 370 | - foreach(array_keys($this->sNamespaces) as $sNamespace) |
|
| 370 | + foreach (array_keys($this->sNamespaces) as $sNamespace) |
|
| 371 | 371 | { |
| 372 | 372 | $offset = 0; |
| 373 | 373 | $sJsNamespace = str_replace('\\', '.', $sNamespace); |
| 374 | 374 | $sJsNamespace .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
| 375 | - while(($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 375 | + while (($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 376 | 376 | { |
| 377 | 377 | $sJsClass = substr($sJsNamespace, 0, $dotPosition); |
| 378 | 378 | // Generate code for this object |
| 379 | - if(!key_exists($sJsClass, $aJsClasses)) |
|
| 379 | + if (!key_exists($sJsClass, $aJsClasses)) |
|
| 380 | 380 | { |
| 381 | 381 | $sCode .= "$sPrefix$sJsClass = {};\n"; |
| 382 | 382 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -385,13 +385,13 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 388 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 389 | 389 | { |
| 390 | 390 | $aConfig = $this->aCallableOptions[$sClassName]; |
| 391 | 391 | $aCommonConfig = key_exists('*', $aConfig) ? $aConfig['*'] : []; |
| 392 | 392 | |
| 393 | 393 | $aMethods = []; |
| 394 | - foreach($xCallableObject->getMethods() as $sMethodName) |
|
| 394 | + foreach ($xCallableObject->getMethods() as $sMethodName) |
|
| 395 | 395 | { |
| 396 | 396 | // Specific options for this method |
| 397 | 397 | $aMethodConfig = key_exists($sMethodName, $aConfig) ? |
@@ -243,8 +243,7 @@ |
||
| 243 | 243 | if($sName == 'separator' || $sName == 'protected') |
| 244 | 244 | { |
| 245 | 245 | $xCallableObject->configure($sName, $xValue); |
| 246 | - } |
|
| 247 | - elseif(is_array($xValue) && $sName != 'include') |
|
| 246 | + } elseif(is_array($xValue) && $sName != 'include') |
|
| 248 | 247 | { |
| 249 | 248 | // These options are to be included in javascript code. |
| 250 | 249 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -61,19 +61,19 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $this->repository = $repository; |
| 63 | 63 | |
| 64 | - if(!empty($_GET['jxncls'])) |
|
| 64 | + if (!empty($_GET['jxncls'])) |
|
| 65 | 65 | { |
| 66 | 66 | $this->sRequestedClass = $_GET['jxncls']; |
| 67 | 67 | } |
| 68 | - if(!empty($_GET['jxnmthd'])) |
|
| 68 | + if (!empty($_GET['jxnmthd'])) |
|
| 69 | 69 | { |
| 70 | 70 | $this->sRequestedMethod = $_GET['jxnmthd']; |
| 71 | 71 | } |
| 72 | - if(!empty($_POST['jxncls'])) |
|
| 72 | + if (!empty($_POST['jxncls'])) |
|
| 73 | 73 | { |
| 74 | 74 | $this->sRequestedClass = $_POST['jxncls']; |
| 75 | 75 | } |
| 76 | - if(!empty($_POST['jxnmthd'])) |
|
| 76 | + if (!empty($_POST['jxnmthd'])) |
|
| 77 | 77 | { |
| 78 | 78 | $this->sRequestedMethod = $_POST['jxnmthd']; |
| 79 | 79 | } |
@@ -100,20 +100,20 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function register($sType, $sClassName, $aOptions) |
| 102 | 102 | { |
| 103 | - if($sType != $this->getName()) |
|
| 103 | + if ($sType != $this->getName()) |
|
| 104 | 104 | { |
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(!is_string($sClassName)) |
|
| 108 | + if (!is_string($sClassName)) |
|
| 109 | 109 | { |
| 110 | 110 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 111 | 111 | } |
| 112 | - if(is_string($aOptions)) |
|
| 112 | + if (is_string($aOptions)) |
|
| 113 | 113 | { |
| 114 | 114 | $aOptions = ['include' => $aOptions]; |
| 115 | 115 | } |
| 116 | - if(!is_array($aOptions)) |
|
| 116 | + if (!is_array($aOptions)) |
|
| 117 | 117 | { |
| 118 | 118 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 119 | 119 | } |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | public function canProcessRequest() |
| 152 | 152 | { |
| 153 | 153 | // Check the validity of the class name |
| 154 | - if($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) |
|
| 154 | + if ($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) |
|
| 155 | 155 | { |
| 156 | 156 | $this->sRequestedClass = null; |
| 157 | 157 | $this->sRequestedMethod = null; |
| 158 | 158 | } |
| 159 | 159 | // Check the validity of the method name |
| 160 | - if($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod)) |
|
| 160 | + if ($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod)) |
|
| 161 | 161 | { |
| 162 | 162 | $this->sRequestedClass = null; |
| 163 | 163 | $this->sRequestedMethod = null; |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function processRequest() |
| 174 | 174 | { |
| 175 | - if(!$this->canProcessRequest()) |
|
| 175 | + if (!$this->canProcessRequest()) |
|
| 176 | 176 | { |
| 177 | 177 | return false; |
| 178 | 178 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | // Find the requested method |
| 183 | 183 | $xCallableObject = $this->repository->getCallableObject($this->sRequestedClass); |
| 184 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 184 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 185 | 185 | { |
| 186 | 186 | // Unable to find the requested object or method |
| 187 | 187 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | } |
| 165 | 165 | else |
| 166 | 166 | { |
| 167 | - // Use underscore as separator, so there's no need to deal with namespace |
|
| 167 | + // Use underscore as separator, so there's no need to deal with namespace |
|
| 168 | 168 | // when generating javascript code. |
| 169 | 169 | $aOptions['separator'] = '_'; |
| 170 | 170 | $aOptions['autoload'] = $this->bAutoloadEnabled; |
@@ -105,33 +105,33 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function register($sType, $sDirectory, $aOptions) |
| 107 | 107 | { |
| 108 | - if($sType != $this->getName()) |
|
| 108 | + if ($sType != $this->getName()) |
|
| 109 | 109 | { |
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if(!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 113 | + if (!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 114 | 114 | { |
| 115 | 115 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 116 | 116 | } |
| 117 | - if(is_string($aOptions)) |
|
| 117 | + if (is_string($aOptions)) |
|
| 118 | 118 | { |
| 119 | 119 | $aOptions = ['namespace' => $aOptions]; |
| 120 | 120 | } |
| 121 | - if(!is_array($aOptions)) |
|
| 121 | + if (!is_array($aOptions)) |
|
| 122 | 122 | { |
| 123 | 123 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $sDirectory = rtrim(trim($sDirectory), DIRECTORY_SEPARATOR); |
| 127 | - if(!is_dir($sDirectory)) |
|
| 127 | + if (!is_dir($sDirectory)) |
|
| 128 | 128 | { |
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | $aOptions['directory'] = $sDirectory; |
| 132 | 132 | |
| 133 | 133 | $sNamespace = key_exists('namespace', $aOptions) ? $aOptions['namespace'] : ''; |
| 134 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 134 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 135 | 135 | { |
| 136 | 136 | $sNamespace = ''; |
| 137 | 137 | } |
@@ -145,17 +145,17 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // Change the keys in $aOptions to have "\" as separator |
| 147 | 147 | $_aOptions = []; |
| 148 | - foreach($aOptions as $sName => $aOption) |
|
| 148 | + foreach ($aOptions as $sName => $aOption) |
|
| 149 | 149 | { |
| 150 | 150 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
| 151 | 151 | $_aOptions[$sName] = $aOption; |
| 152 | 152 | } |
| 153 | 153 | $aOptions = $_aOptions; |
| 154 | 154 | |
| 155 | - if(($sNamespace)) |
|
| 155 | + if (($sNamespace)) |
|
| 156 | 156 | { |
| 157 | 157 | // Register the dir with PSR4 autoloading |
| 158 | - if(($this->xAutoloader)) |
|
| 158 | + if (($this->xAutoloader)) |
|
| 159 | 159 | { |
| 160 | 160 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 161 | 161 | } |
@@ -161,8 +161,7 @@ |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $this->repository->addNamespace($sNamespace, $aOptions); |
| 164 | - } |
|
| 165 | - else |
|
| 164 | + } else |
|
| 166 | 165 | { |
| 167 | 166 | // Use underscore as separator, so there's no need to deal with namespace |
| 168 | 167 | // when generating javascript code. |