@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | $array['fields'][] = $field->__toArray(); |
| 43 | 43 | } |
| 44 | 44 | usort($array['fields'], function($fA, $fB) { |
| 45 | - if((bool)$fA['required'] !== (bool)$fB['required']) { |
|
| 46 | - if((bool)$fa['required']) { |
|
| 45 | + if ((bool)$fA['required'] !== (bool)$fB['required']) { |
|
| 46 | + if ((bool)$fa['required']) { |
|
| 47 | 47 | return -1; |
| 48 | - } else { |
|
| 48 | + }else { |
|
| 49 | 49 | return 1; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | return ($aOrder < $bOrder) ? -1 : 1; |
| 58 | 58 | }); |
| 59 | - foreach($this->actions as $action) { |
|
| 59 | + foreach ($this->actions as $action) { |
|
| 60 | 60 | $array['actions'][] = $action->__toArray(); |
| 61 | 61 | } |
| 62 | 62 | return $array; |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | public static function getClassToCall(array $action) |
| 20 | 20 | { |
| 21 | 21 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
| 22 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
| 22 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
| 23 | 23 | $reflectionClass = new \ReflectionClass($actionClass); |
| 24 | - if($reflectionClass->hasMethod('getInstance')) { |
|
| 24 | + if ($reflectionClass->hasMethod('getInstance')) { |
|
| 25 | 25 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
| 26 | - } else { |
|
| 26 | + }else { |
|
| 27 | 27 | $class = new $actionClass; |
| 28 | 28 | } |
| 29 | 29 | return $class; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $expr = preg_quote($expr, '/'); |
| 113 | 113 | $expr = str_replace('###', '(.*)', $expr); |
| 114 | 114 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
| 115 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
| 115 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
| 116 | 116 | return $matched; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
| 125 | 125 | { |
| 126 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 127 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
| 126 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 127 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
| 128 | 128 | $templatesPath = 'templates'; |
| 129 | 129 | $publicPath = 'public'; |
| 130 | 130 | $modelsPath = 'models'; |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | $modelsPath = ucfirst($modelsPath); |
| 135 | 135 | } |
| 136 | 136 | if ($class->hasConstant('TPL')) { |
| 137 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
| 137 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
| 138 | 138 | } |
| 139 | 139 | return [ |
| 140 | 140 | 'base' => $path, |
| 141 | - 'template' => $path . $templatesPath, |
|
| 142 | - 'model' => $path . $modelsPath, |
|
| 143 | - 'public' => $path . $publicPath, |
|
| 141 | + 'template' => $path.$templatesPath, |
|
| 142 | + 'model' => $path.$modelsPath, |
|
| 143 | + 'public' => $path.$publicPath, |
|
| 144 | 144 | ]; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -164,12 +164,12 @@ discard block |
||
| 164 | 164 | foreach ($parameters as $param) { |
| 165 | 165 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 166 | 166 | $params[$param->getName()] = $param->getDefaultValue(); |
| 167 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
| 168 | - } elseif(!$param->isOptional()) { |
|
| 167 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
| 168 | + } elseif (!$param->isOptional()) { |
|
| 169 | 169 | $requirements[] = $param->getName(); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | - } else { |
|
| 172 | + }else { |
|
| 173 | 173 | $default = $regex; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $httpMethod = self::extractReflectionHttpMethod($docComments); |
| 266 | 266 | $icon = self::extractDocIcon($docComments); |
| 267 | 267 | $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
| 268 | - $route = $httpMethod . "#|#" . $regex; |
|
| 268 | + $route = $httpMethod."#|#".$regex; |
|
| 269 | 269 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
| 270 | 270 | $info = [ |
| 271 | 271 | 'method' => $method->getName(), |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $dump = ''; |
| 118 | 118 | try { |
| 119 | 119 | $dump = $this->tpl->render($tpl, $vars); |
| 120 | - } catch (\Exception $e) { |
|
| 120 | + }catch (\Exception $e) { |
|
| 121 | 121 | Logger::log($e->getMessage(), LOG_ERR); |
| 122 | 122 | } |
| 123 | 123 | return $dump; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | public function regenerateTemplates() |
| 145 | 145 | { |
| 146 | 146 | $this->generateTemplatesCache(); |
| 147 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 147 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 148 | 148 | $translations = []; |
| 149 | 149 | if (is_array($domains)) { |
| 150 | 150 | $translations = $this->parsePathTranslations($domains); |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | // force compilation |
| 167 | 167 | if ($file->isFile()) { |
| 168 | 168 | try { |
| 169 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
| 170 | - } catch (\Exception $e) { |
|
| 169 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
| 170 | + }catch (\Exception $e) { |
|
| 171 | 171 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | 'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION, |
| 229 | 229 | 'getQuery' => TemplateFunctions::GET_QUERY_FUNCTION, |
| 230 | 230 | ]; |
| 231 | - foreach($functions as $name => $function) { |
|
| 231 | + foreach ($functions as $name => $function) { |
|
| 232 | 232 | $this->addTemplateFunction($name, $function); |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | private function loadDomains() |
| 249 | 249 | { |
| 250 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 250 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 251 | 251 | if (null !== $domains) { |
| 252 | 252 | foreach ($domains as $domain => $paths) { |
| 253 | 253 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | { |
| 263 | 263 | $loader = new FilesystemLoader(GeneratorHelper::getTemplatePath()); |
| 264 | 264 | $this->tpl = new Environment($loader, array( |
| 265 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
| 265 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
| 266 | 266 | 'debug' => (bool)$this->debug, |
| 267 | 267 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
| 268 | 268 | )); |