@@ -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': |
@@ -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(), |