@@ -37,20 +37,20 @@ discard block |
||
| 37 | 37 | $behaviors = $tableMap->getBehaviors(); |
| 38 | 38 | foreach ($map::getFieldNames() as $field) { |
| 39 | 39 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
| 40 | - if(null !== $fDto) { |
|
| 40 | + if (null !== $fDto) { |
|
| 41 | 41 | $form->addField($fDto); |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(array_key_exists('i18n', $behaviors)) { |
|
| 46 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
| 47 | - if(null !== $relateI18n) { |
|
| 45 | + if (array_key_exists('i18n', $behaviors)) { |
|
| 46 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
| 47 | + if (null !== $relateI18n) { |
|
| 48 | 48 | $i18NTableMap = $relateI18n->getLocalTable(); |
| 49 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
| 49 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
| 50 | 50 | $columnName = self::getColumnMapName($columnMap); |
| 51 | - if(!$form->fieldExists($columnName)) { |
|
| 51 | + if (!$form->fieldExists($columnName)) { |
|
| 52 | 52 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
| 53 | - if(null !== $fDto) { |
|
| 53 | + if (null !== $fDto) { |
|
| 54 | 54 | $fDto->pk = false; |
| 55 | 55 | $fDto->required = true; |
| 56 | 56 | $form->addField($fDto); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $fDto->entity = $relatedModel; |
| 81 | 81 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
| 82 | 82 | $fDto->relatedField = $relatedField->getPhpName(); |
| 83 | - $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel); |
|
| 83 | + $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel); |
|
| 84 | 84 | return $fDto; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | $column = null; |
| 189 | 189 | try { |
| 190 | - foreach($tableMap->getColumns() as $tableMapColumn) { |
|
| 190 | + foreach ($tableMap->getColumns() as $tableMapColumn) { |
|
| 191 | 191 | $columnName = $tableMapColumn->getPhpName(); |
| 192 | - if(preg_match('/^'.$field.'$/i', $columnName)) { |
|
| 192 | + if (preg_match('/^'.$field.'$/i', $columnName)) { |
|
| 193 | 193 | $column = $tableMapColumn; |
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - } catch (\Exception $e) { |
|
| 197 | + }catch (\Exception $e) { |
|
| 198 | 198 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 199 | 199 | } |
| 200 | 200 | return $column; |
@@ -208,18 +208,18 @@ discard block |
||
| 208 | 208 | private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
| 209 | 209 | { |
| 210 | 210 | $tableField = $column->getFullyQualifiedName(); |
| 211 | - if(is_array($value)) { |
|
| 211 | + if (is_array($value)) { |
|
| 212 | 212 | $query->add($tableField, $value, Criteria::IN); |
| 213 | 213 | } elseif (preg_match('/^\[/', $value) && preg_match('/\]$/', $value)) { |
| 214 | 214 | $query->add($tableField, explode(',', preg_replace('/(\[|\])/', '', $value)), Criteria::IN); |
| 215 | 215 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
| 216 | 216 | $text = preg_replace('/(\'|\")/', '', $value); |
| 217 | 217 | $text = preg_replace('/\ /', '%', $text); |
| 218 | - $query->add($tableField, '%' . $text . '%', Criteria::LIKE); |
|
| 219 | - } else { |
|
| 220 | - if(null !== $column->getValueSet()) { |
|
| 218 | + $query->add($tableField, '%'.$text.'%', Criteria::LIKE); |
|
| 219 | + }else { |
|
| 220 | + if (null !== $column->getValueSet()) { |
|
| 221 | 221 | $valueSet = $column->getValueSet(); |
| 222 | - if(in_array($value, $valueSet)) { |
|
| 222 | + if (in_array($value, $valueSet)) { |
|
| 223 | 223 | $value = array_search($value, $valueSet); |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -239,31 +239,31 @@ discard block |
||
| 239 | 239 | $sep = ''; |
| 240 | 240 | foreach ($tableMap->getColumns() as $column) { |
| 241 | 241 | if ($column->isText()) { |
| 242 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 242 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
| 243 | 243 | $sep = ', " ", '; |
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | - foreach($tableMap->getRelations() as $relation) { |
|
| 247 | - if(preg_match('/I18n$/i', $relation->getName())) { |
|
| 246 | + foreach ($tableMap->getRelations() as $relation) { |
|
| 247 | + if (preg_match('/I18n$/i', $relation->getName())) { |
|
| 248 | 248 | $localeTableMap = $relation->getLocalTable(); |
| 249 | 249 | foreach ($localeTableMap->getColumns() as $column) { |
| 250 | 250 | if ($column->isText()) { |
| 251 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 251 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
| 252 | 252 | $sep = ', " ", '; |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | foreach ($extraColumns as $extra => $name) { |
| 258 | - if(!preg_match("/(COUNT|DISTINCT|SUM|MAX|MIN|GROUP)/i", $extra)) { |
|
| 259 | - $exp .= $sep . $extra; |
|
| 258 | + if (!preg_match("/(COUNT|DISTINCT|SUM|MAX|MIN|GROUP)/i", $extra)) { |
|
| 259 | + $exp .= $sep.$extra; |
|
| 260 | 260 | $sep = ', " ", '; |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | $exp .= ")"; |
| 264 | 264 | $text = preg_replace('/(\'|\")/', '', $value); |
| 265 | 265 | $text = preg_replace('/\ /', '%', $text); |
| 266 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
| 266 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null) |
| 290 | 290 | { |
| 291 | - $queryReflector = new \ReflectionClass($modelNameNamespace . "Query"); |
|
| 291 | + $queryReflector = new \ReflectionClass($modelNameNamespace."Query"); |
|
| 292 | 292 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
| 293 | 293 | $query = $queryReflector->getMethod('create')->invoke($con); |
| 294 | 294 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | } elseif ($mappedColumn->isText()) { |
| 318 | 318 | if ($mappedColumn->getSize() > 100) { |
| 319 | 319 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
| 320 | - } else { |
|
| 320 | + }else { |
|
| 321 | 321 | $fDto = self::generateStringField($field, $required); |
| 322 | 322 | } |
| 323 | 323 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | } elseif (in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) { |
| 334 | 334 | $fDto = self::generateEnumField($field, $required); |
| 335 | 335 | foreach ($mappedColumn->getValueSet() as $value) { |
| 336 | - switch(Config::getParam('api.field.case', TableMap::TYPE_PHPNAME)) { |
|
| 336 | + switch (Config::getParam('api.field.case', TableMap::TYPE_PHPNAME)) { |
|
| 337 | 337 | default: |
| 338 | 338 | case TableMap::TYPE_PHPNAME: |
| 339 | 339 | $fieldName = $mappedColumn->getPhpName(); |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | $fDto->pk = true; |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | - switch(Config::getParam('api.field.case', TableMap::TYPE_PHPNAME)) { |
|
| 360 | + switch (Config::getParam('api.field.case', TableMap::TYPE_PHPNAME)) { |
|
| 361 | 361 | default: |
| 362 | 362 | case TableMap::TYPE_PHPNAME: |
| 363 | 363 | $fDto->name = $mappedColumn->getPhpName(); |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | public static function extractPrimaryKeyColumnName(TableMap $tableMap) { |
| 383 | 383 | $modelPk = null; |
| 384 | - foreach($tableMap->getPrimaryKeys() as $pk) { |
|
| 384 | + foreach ($tableMap->getPrimaryKeys() as $pk) { |
|
| 385 | 385 | $modelPk = $pk; |
| 386 | 386 | break; |
| 387 | 387 | } |
@@ -390,15 +390,15 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | private static function mapResult(ActiveRecordInterface $model, array $data = []) { |
| 392 | 392 | $result = []; |
| 393 | - foreach($data as $key => $value) { |
|
| 393 | + foreach ($data as $key => $value) { |
|
| 394 | 394 | try { |
| 395 | 395 | $realValue = $model->getByName($key); |
| 396 | - } catch(\Exception $e) { |
|
| 396 | + }catch (\Exception $e) { |
|
| 397 | 397 | $realValue = $value; |
| 398 | 398 | } |
| 399 | - if(Api::API_MODEL_KEY_FIELD === $key) { |
|
| 399 | + if (Api::API_MODEL_KEY_FIELD === $key) { |
|
| 400 | 400 | $result[$key] = (integer)$realValue; |
| 401 | - } else { |
|
| 401 | + }else { |
|
| 402 | 402 | $result[$key] = $realValue; |
| 403 | 403 | } |
| 404 | 404 | } |
@@ -415,14 +415,14 @@ discard block |
||
| 415 | 415 | $objTableMap = get_class($formatter->getTableMap()); |
| 416 | 416 | /** @var TableMapTrait $objTableMap */ |
| 417 | 417 | $objData = $data; |
| 418 | - foreach($objTableMap::getFieldNames() as $field) { |
|
| 419 | - if(!array_key_exists($field, $objData)) { |
|
| 418 | + foreach ($objTableMap::getFieldNames() as $field) { |
|
| 419 | + if (!array_key_exists($field, $objData)) { |
|
| 420 | 420 | $objData[$field] = null; |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | $obj = @$formatter->getAllObjectsFromRow($objData); |
| 424 | 424 | $result = self::mapResult($obj, $data); |
| 425 | - if(!preg_match('/' . $modelPk->getPhpName() . '/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
| 425 | + if (!preg_match('/'.$modelPk->getPhpName().'/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
| 426 | 426 | unset($result[$modelPk->getPhpName()]); |
| 427 | 427 | } |
| 428 | 428 | return $result; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | */ |
| 434 | 434 | public static function getFieldTypes() { |
| 435 | 435 | $configType = Config::getParam('api.field.case'); |
| 436 | - switch($configType) { |
|
| 436 | + switch ($configType) { |
|
| 437 | 437 | default: |
| 438 | 438 | case 'UpperCamelCase': |
| 439 | 439 | case TableMap::TYPE_PHPNAME: |
@@ -459,11 +459,11 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | public static function getColumnMapName(ColumnMap $field) { |
| 462 | - switch(self::getFieldTypes()) { |
|
| 462 | + switch (self::getFieldTypes()) { |
|
| 463 | 463 | default: |
| 464 | 464 | case 'UpperCamelCase': |
| 465 | 465 | case TableMap::TYPE_PHPNAME: |
| 466 | - $columnName =$field->getPhpName(); |
|
| 466 | + $columnName = $field->getPhpName(); |
|
| 467 | 467 | break; |
| 468 | 468 | case 'camelCase': |
| 469 | 469 | case 'lowerCamelCase': |