@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | if (!preg_match('/^ROOT/i', $module)) { |
| 40 | 40 | $modules[] = [ |
| 41 | 41 | 'name' => $module, |
| 42 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
| 42 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
| 43 | 43 | ]; |
| 44 | 44 | } |
| 45 | - } catch (\Exception $e) { |
|
| 45 | + }catch (\Exception $e) { |
|
| 46 | 46 | $modules[] = $e->getMessage(); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function extractApiEndpoints(array $module) |
| 62 | 62 | { |
| 63 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
| 63 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
| 64 | 64 | $module_name = $module['name']; |
| 65 | 65 | $endpoints = []; |
| 66 | 66 | if (file_exists($module_path)) { |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | if (count($finder)) { |
| 70 | 70 | /** @var \SplFileInfo $file */ |
| 71 | 71 | foreach ($finder as $file) { |
| 72 | - $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
| 72 | + $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
| 73 | 73 | $info = $this->extractApiInfo($namespace, $module_name); |
| 74 | - if(!empty($info)) { |
|
| 74 | + if (!empty($info)) { |
|
| 75 | 75 | $endpoints[$namespace] = $info; |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | public function extractApiInfo($namespace, $module) |
| 91 | 91 | { |
| 92 | 92 | $info = []; |
| 93 | - if(class_exists($namespace)) { |
|
| 93 | + if (class_exists($namespace)) { |
|
| 94 | 94 | $reflection = new \ReflectionClass($namespace); |
| 95 | 95 | foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
| 96 | 96 | try { |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | if (NULL !== $mInfo) { |
| 99 | 99 | $info[] = $mInfo; |
| 100 | 100 | } |
| 101 | - } catch (\Exception $e) { |
|
| 101 | + }catch (\Exception $e) { |
|
| 102 | 102 | Logger::getInstance()->errorLog($e->getMessage()); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | protected function extractReturn($model, $comments = '') |
| 258 | 258 | { |
| 259 | - $modelDto = []; |
|
| 259 | + $modelDto = []; |
|
| 260 | 260 | preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes); |
| 261 | 261 | if (count($returnTypes)) { |
| 262 | 262 | // Extract principal DTO information |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
| 310 | 310 | $payload = $this->extractDtoProperties($namespace); |
| 311 | 311 | } |
| 312 | - } catch (\Exception $e) { |
|
| 312 | + }catch (\Exception $e) { |
|
| 313 | 313 | Logger::getInstance()->errorLog($e->getMessage()); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
| 347 | 347 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
| 348 | 348 | } |
| 349 | - } catch (\Exception $e) { |
|
| 349 | + }catch (\Exception $e) { |
|
| 350 | 350 | jpre($e->getMessage()); |
| 351 | 351 | Logger::getInstance()->errorLog($e->getMessage()); |
| 352 | 352 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | public static function translateSwaggerFormats($format) |
| 366 | 366 | { |
| 367 | - switch(strtolower($format)) { |
|
| 367 | + switch (strtolower($format)) { |
|
| 368 | 368 | case 'bool': |
| 369 | 369 | case 'boolean': |
| 370 | 370 | $swaggerType = 'boolean'; |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | ]]); |
| 426 | 426 | if (array_key_exists($subDtoName, $subDto)) { |
| 427 | 427 | $definitions = $subDto; |
| 428 | - } else { |
|
| 428 | + }else { |
|
| 429 | 429 | $definitions[$subDtoName] = $subDto; |
| 430 | 430 | } |
| 431 | 431 | $dto['properties'][$field] = [ |
| 432 | - '$ref' => "#/definitions/" . $subDtoName, |
|
| 432 | + '$ref' => "#/definitions/".$subDtoName, |
|
| 433 | 433 | ]; |
| 434 | - } else { |
|
| 434 | + }else { |
|
| 435 | 435 | list($type, $format) = self::translateSwaggerFormats($format); |
| 436 | 436 | $dto['properties'][$field] = [ |
| 437 | 437 | "type" => $type, |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | ] |
| 471 | 471 | ] |
| 472 | 472 | ]; |
| 473 | - foreach($endpoints as $model) { |
|
| 473 | + foreach ($endpoints as $model) { |
|
| 474 | 474 | foreach ($model as $endpoint) { |
| 475 | 475 | $dtos += self::extractSwaggerDefinition($endpoint); |
| 476 | 476 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | protected function extractDtoName($dto, $isArray = false) |
| 490 | 490 | { |
| 491 | 491 | $dto = explode('\\', $dto); |
| 492 | - $modelDto = array_pop($dto) . "Dto"; |
|
| 492 | + $modelDto = array_pop($dto)."Dto"; |
|
| 493 | 493 | if ($isArray) { |
| 494 | 494 | $modelDto .= "List"; |
| 495 | 495 | } |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | } elseif ($mappedColumn->isNumeric()) { |
| 39 | 39 | $fDto = self::generateNumericField($field, $required); |
| 40 | 40 | } elseif ($mappedColumn->isText()) { |
| 41 | - if($mappedColumn->getSize() > 100) { |
|
| 41 | + if ($mappedColumn->getSize() > 100) { |
|
| 42 | 42 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
| 43 | - } else { |
|
| 43 | + }else { |
|
| 44 | 44 | $fDto = self::generateStringField($field, $required); |
| 45 | 45 | } |
| 46 | 46 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | $fDto = self::generatePasswordField($field, $required); |
| 50 | 50 | } elseif (in_array($mappedColumn->getType(), [PropelTypes::TIMESTAMP, PropelTypes::DATE, PropelTypes::BU_DATE, PropelTypes::BU_TIMESTAMP])) { |
| 51 | 51 | $fDto = self::createField($field, Field::TEXT_TYPE, $required); |
| 52 | - } elseif(in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) { |
|
| 52 | + } elseif (in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) { |
|
| 53 | 53 | $fDto = self::generateEnumField($field, $required); |
| 54 | - foreach($mappedColumn->getValueSet() as $value) { |
|
| 54 | + foreach ($mappedColumn->getValueSet() as $value) { |
|
| 55 | 55 | $fDto->data[] = [ |
| 56 | 56 | $field => $value, |
| 57 | 57 | "Label" => _($value), |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if(null !== $fDto) { |
|
| 62 | + if (null !== $fDto) { |
|
| 63 | 63 | $fDto->size = $mappedColumn->getSize(); |
| 64 | 64 | $form->addField($fDto); |
| 65 | 65 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $fDto->entity = $relatedModel; |
| 84 | 84 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
| 85 | 85 | $fDto->relatedField = $relatedField->getPhpName(); |
| 86 | - $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel); |
|
| 86 | + $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel); |
|
| 87 | 87 | return $fDto; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | public static function checkFieldExists(TableMap $tableMap, $field) { |
| 189 | 189 | try { |
| 190 | 190 | $column = $tableMap->getColumnByPhpName($field); |
| 191 | - } catch(\Exception $e) { |
|
| 191 | + }catch (\Exception $e) { |
|
| 192 | 192 | Logger::log($e->getMessage(), LOG_ERR); |
| 193 | 193 | $column = null; |
| 194 | 194 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param ModelCriteria $quwuery |
| 201 | 201 | * @param mixed $value |
| 202 | 202 | */ |
| 203 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) { |
|
| 203 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) { |
|
| 204 | 204 | $tableField = $column->getPhpName(); |
| 205 | 205 | if (preg_match('/^<=/', $value)) { |
| 206 | 206 | $query->filterBy($tableField, substr($value, 2, strlen($value)), Criteria::LESS_EQUAL); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $text = preg_replace('/(\'|\")/', '', $value); |
| 215 | 215 | $text = preg_replace('/\ /', '%', $text); |
| 216 | 216 | $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE); |
| 217 | - } else { |
|
| 217 | + }else { |
|
| 218 | 218 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -225,23 +225,23 @@ discard block |
||
| 225 | 225 | * @param array $extraColumns |
| 226 | 226 | * @param mixed $value |
| 227 | 227 | */ |
| 228 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) { |
|
| 228 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) { |
|
| 229 | 229 | $exp = 'CONCAT('; |
| 230 | 230 | $sep = ''; |
| 231 | - foreach($tableMap->getColumns() as $column) { |
|
| 232 | - if($column->isText()) { |
|
| 233 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 231 | + foreach ($tableMap->getColumns() as $column) { |
|
| 232 | + if ($column->isText()) { |
|
| 233 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
| 234 | 234 | $sep = ', " ", '; |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | - foreach($extraColumns as $extra => $name) { |
|
| 238 | - $exp .= $sep . $extra; |
|
| 237 | + foreach ($extraColumns as $extra => $name) { |
|
| 238 | + $exp .= $sep.$extra; |
|
| 239 | 239 | $sep = ', " ", '; |
| 240 | 240 | } |
| 241 | 241 | $exp .= ")"; |
| 242 | 242 | $text = preg_replace('/(\'|\")/', '', $value); |
| 243 | 243 | $text = preg_replace('/\ /', '%', $text); |
| 244 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
| 244 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @param string $field |
| 252 | 252 | * @param mixed $value |
| 253 | 253 | */ |
| 254 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) { |
|
| 254 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) { |
|
| 255 | 255 | if ($column = self::checkFieldExists($tableMap, $field)) { |
| 256 | 256 | self::addQueryFilter($column, $query, $value); |
| 257 | 257 | } |