@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | /** |
| 141 | 141 | * Método que extrae los parámetros de una función |
| 142 | 142 | * |
| 143 | - * @param array $sr |
|
| 143 | + * @param string[] $sr |
|
| 144 | 144 | * @param \ReflectionMethod $method |
| 145 | 145 | * |
| 146 | 146 | * @return array |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @param string $docComments |
| 209 | 209 | * |
| 210 | - * @return bool |
|
| 210 | + * @return string |
|
| 211 | 211 | */ |
| 212 | 212 | public static function extractReflectionCacheability($docComments) |
| 213 | 213 | { |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public static function getClassToCall($action) |
| 21 | 21 | { |
| 22 | 22 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
| 23 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
| 23 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
| 24 | 24 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
| 25 | 25 | return $class; |
| 26 | 26 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $expr = preg_quote($expr, '/'); |
| 107 | 107 | $expr = str_replace('###', '(.*)', $expr); |
| 108 | 108 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
| 109 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
| 109 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
| 110 | 110 | return $matched; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
| 119 | 119 | { |
| 120 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 121 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
| 120 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 121 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
| 122 | 122 | $tpl_path = "templates"; |
| 123 | 123 | $public_path = "public"; |
| 124 | 124 | $model_path = "models"; |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | $model_path = ucfirst($model_path); |
| 129 | 129 | } |
| 130 | 130 | if ($class->hasConstant("TPL")) { |
| 131 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
| 131 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
| 132 | 132 | } |
| 133 | 133 | return [ |
| 134 | - "template" => $path . $tpl_path, |
|
| 135 | - "model" => $path . $model_path, |
|
| 136 | - "public" => $path . $public_path, |
|
| 134 | + "template" => $path.$tpl_path, |
|
| 135 | + "model" => $path.$model_path, |
|
| 136 | + "public" => $path.$public_path, |
|
| 137 | 137 | ]; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | if (count($parameters) > 0) foreach ($parameters as $param) { |
| 156 | 156 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 157 | 157 | $params[$param->getName()] = $param->getDefaultValue(); |
| 158 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
| 158 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
| 159 | 159 | } |
| 160 | - } else $default = $regex; |
|
| 160 | + }else $default = $regex; |
|
| 161 | 161 | |
| 162 | 162 | return array($regex, $default, $params); |
| 163 | 163 | } |
@@ -225,10 +225,10 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | $is_enabled = true; |
| 227 | 227 | // For non api routes |
| 228 | - if(strlen($api) > 0 && preg_match('/admin/i', $route)) { |
|
| 228 | + if (strlen($api) > 0 && preg_match('/admin/i', $route)) { |
|
| 229 | 229 | // If route is for api, check if admin is enabled in config |
| 230 | 230 | $admin_enabled = Config::getInstance()->get('api.admin'); |
| 231 | - if(empty($admin_enabled)) { |
|
| 231 | + if (empty($admin_enabled)) { |
|
| 232 | 232 | $is_enabled = false; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments); |
| 255 | 255 | $label = RouterHelper::extractReflectionLabel($docComments); |
| 256 | - if(self::checkCanAddRoute($regex, $api)) { |
|
| 257 | - $route = $httpMethod . "#|#" . $regex; |
|
| 256 | + if (self::checkCanAddRoute($regex, $api)) { |
|
| 257 | + $route = $httpMethod."#|#".$regex; |
|
| 258 | 258 | $info = [ |
| 259 | 259 | "method" => $method->getName(), |
| 260 | 260 | "params" => $params, |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $default = Config::getInstance()->get('admin_action') ?: 'admin-login'; |
| 283 | 283 | |
| 284 | 284 | } |
| 285 | - if(null !== $default) { |
|
| 285 | + if (null !== $default) { |
|
| 286 | 286 | return Router::getInstance()->execute(Router::getInstance()->getRoute($default)); |
| 287 | 287 | } |
| 288 | 288 | return null; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $tableMap = $tableMapClass::getTableMap(); |
| 165 | 165 | try { |
| 166 | 166 | $column = $tableMap->getColumnByPhpName($field); |
| 167 | - } catch(\Exception $e) { |
|
| 167 | + }catch (\Exception $e) { |
|
| 168 | 168 | Logger::log($e->getMessage(), LOG_ERR); |
| 169 | 169 | $column = null; |
| 170 | 170 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @param ModelCriteria $query |
| 178 | 178 | */ |
| 179 | - private function addOrders(ModelCriteria &$query) |
|
| 179 | + private function addOrders(ModelCriteria & $query) |
|
| 180 | 180 | { |
| 181 | 181 | $orderAdded = FALSE; |
| 182 | 182 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $orderAdded = TRUE; |
| 185 | 185 | if ($direction === Order::ASC) { |
| 186 | 186 | $query->addAscendingOrderByColumn($column->getPhpName()); |
| 187 | - } else { |
|
| 187 | + }else { |
|
| 188 | 188 | $query->addDescendingOrderByColumn($column->getPhpName()); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @param ModelCriteria $query |
| 201 | 201 | */ |
| 202 | - private function addExtraColumns(ModelCriteria &$query) |
|
| 202 | + private function addExtraColumns(ModelCriteria & $query) |
|
| 203 | 203 | { |
| 204 | 204 | if (!empty($this->extraColumns)) { |
| 205 | 205 | foreach ($this->extraColumns as $expression => $columnName) { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * |
| 214 | 214 | * @param ModelCriteria $query |
| 215 | 215 | */ |
| 216 | - protected function joinTables(ModelCriteria &$query) |
|
| 216 | + protected function joinTables(ModelCriteria & $query) |
|
| 217 | 217 | { |
| 218 | 218 | //TODO for specific implementations |
| 219 | 219 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | protected function parseExtraColumns() { |
| 225 | 225 | $columns = []; |
| 226 | - foreach($this->extraColumns as $key => $columnName) { |
|
| 226 | + foreach ($this->extraColumns as $key => $columnName) { |
|
| 227 | 227 | $columns[$columnName] = strtolower($columnName); |
| 228 | 228 | } |
| 229 | 229 | return $columns; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @param ModelCriteria $query |
| 236 | 236 | */ |
| 237 | - private function addFilters(ModelCriteria &$query) |
|
| 237 | + private function addFilters(ModelCriteria & $query) |
|
| 238 | 238 | { |
| 239 | 239 | if (count($this->query) > 0) { |
| 240 | 240 | $extraColumns = $this->parseExtraColumns(); |
@@ -253,16 +253,16 @@ discard block |
||
| 253 | 253 | $text = preg_replace('/(\'|\")/', '', $value); |
| 254 | 254 | $text = preg_replace('/\ /', '%', $text); |
| 255 | 255 | $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE); |
| 256 | - } else { |
|
| 256 | + }else { |
|
| 257 | 257 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
| 258 | 258 | } |
| 259 | - } elseif(false !== ($index = array_search(strtolower($field), $extraColumns))) { |
|
| 259 | + } elseif (false !== ($index = array_search(strtolower($field), $extraColumns))) { |
|
| 260 | 260 | $exp = array_search($index, $this->extraColumns); |
| 261 | - $query->where($exp . Criteria::LIKE . '"'.$value.'"'); |
|
| 262 | - } else { |
|
| 261 | + $query->where($exp.Criteria::LIKE.'"'.$value.'"'); |
|
| 262 | + }else { |
|
| 263 | 263 | $tableField = null; |
| 264 | 264 | } |
| 265 | - if(null !== $tableField) { |
|
| 265 | + if (null !== $tableField) { |
|
| 266 | 266 | |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | list($page, $limit) = $this->extractPagination(); |
| 285 | 285 | if ($limit == -1) { |
| 286 | 286 | $this->list = $query->find($this->con); |
| 287 | - } else { |
|
| 287 | + }else { |
|
| 288 | 288 | $this->list = $query->paginate($page, $limit, $this->con); |
| 289 | 289 | } |
| 290 | - } catch (\Exception $e) { |
|
| 290 | + }catch (\Exception $e) { |
|
| 291 | 291 | Logger::log($e->getMessage(), LOG_ERR); |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | $this->joinTables($query); |
| 305 | 305 | $this->addExtraColumns($query); |
| 306 | 306 | $this->model = $query->findPk($pk); |
| 307 | - } catch (\Exception $e) { |
|
| 307 | + }catch (\Exception $e) { |
|
| 308 | 308 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $saved = TRUE; |
| 393 | 393 | $model = $this->model->toArray(); |
| 394 | 394 | } |
| 395 | - } catch (\Exception $e) { |
|
| 395 | + }catch (\Exception $e) { |
|
| 396 | 396 | Logger::log($e->getMessage(), LOG_ERR); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $this->model->delete($this->con); |
| 421 | 421 | $deleted = TRUE; |
| 422 | 422 | } |
| 423 | - } catch (\Exception $e) { |
|
| 423 | + }catch (\Exception $e) { |
|
| 424 | 424 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | private function extractQuery() |
| 466 | 466 | { |
| 467 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
| 467 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
| 468 | 468 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
| 469 | 469 | $query = $queryReflector->getMethod('create')->invoke($this->con); |
| 470 | 470 | |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | if (null !== $this->con && $this->con->inTransaction()) { |
| 509 | 509 | if ($status === 200) { |
| 510 | 510 | $this->con->commit(); |
| 511 | - } else { |
|
| 511 | + }else { |
|
| 512 | 512 | $this->con->rollBack(); |
| 513 | 513 | } |
| 514 | 514 | } |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | return $this->render('api.admin.html.twig', array( |
| 553 | 553 | "api" => $this->getApi(), |
| 554 | 554 | "domain" => $this->domain, |
| 555 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)), |
|
| 555 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)), |
|
| 556 | 556 | ), [], ''); |
| 557 | 557 | } |
| 558 | 558 | |
@@ -586,12 +586,12 @@ discard block |
||
| 586 | 586 | $pages = 0; |
| 587 | 587 | try { |
| 588 | 588 | $this->paginate(); |
| 589 | - if(null !== $this->list) { |
|
| 589 | + if (null !== $this->list) { |
|
| 590 | 590 | $return = $this->list->toArray(); |
| 591 | 591 | $total = $this->list->getNbResults(); |
| 592 | 592 | $pages = $this->list->getLastPage(); |
| 593 | 593 | } |
| 594 | - } catch (\Exception $e) { |
|
| 594 | + }catch (\Exception $e) { |
|
| 595 | 595 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 596 | 596 | } |
| 597 | 597 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | $return = array(); |
| 611 | 611 | if (NULL === $model && method_exists($model, 'toArray')) { |
| 612 | 612 | $code = 404; |
| 613 | - } else { |
|
| 613 | + }else { |
|
| 614 | 614 | $return = $model->toArray(); |
| 615 | 615 | } |
| 616 | 616 | |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | } elseif (in_array($mappedColumn->getType(), [PropelTypes::TIMESTAMP])) { |
| 44 | 44 | $fDto = self::createField($field, Field::TEXT_TYPE, $required); |
| 45 | 45 | $fDto->readonly = true; |
| 46 | - } elseif(in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) { |
|
| 46 | + } elseif (in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) { |
|
| 47 | 47 | $fDto = self::generateEnumField($field, $required); |
| 48 | - foreach($mappedColumn->getValueSet() as $value) { |
|
| 48 | + foreach ($mappedColumn->getValueSet() as $value) { |
|
| 49 | 49 | $fDto->data[] = [ |
| 50 | 50 | $field => $value, |
| 51 | 51 | "Label" => _($value), |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(null !== $fDto) { |
|
| 56 | + if (null !== $fDto) { |
|
| 57 | 57 | $form->addField($fDto); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $fDto->entity = $relatedModel; |
| 77 | 77 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
| 78 | 78 | $fDto->relatedField = $relatedField->getPhpName(); |
| 79 | - $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel); |
|
| 79 | + $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel); |
|
| 80 | 80 | return $fDto; |
| 81 | 81 | } |
| 82 | 82 | |