@@ -483,7 +483,9 @@ |
||
| 483 | 483 | |
| 484 | 484 | $c = 0; |
| 485 | 485 | foreach($updateFields as $column => $value) { |
| 486 | - if($c>0)$sql .= ", "; |
|
| 486 | + if($c>0) { |
|
| 487 | + $sql .= ", "; |
|
| 488 | + } |
|
| 487 | 489 | $sql .= '`'.$column . "` = '". $value."'"; |
| 488 | 490 | $c++; |
| 489 | 491 | } |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $this->fields = array_keys($this->getClassMetadata()->fieldMappings); |
| 51 | 51 | |
| 52 | - $entityName = explode('\\', strtolower($this->getEntityName()) ); |
|
| 53 | - $entityName = $entityName[count($entityName)-1]; |
|
| 52 | + $entityName = explode('\\', strtolower($this->getEntityName())); |
|
| 53 | + $entityName = $entityName[count($entityName) - 1]; |
|
| 54 | 54 | $entityAlias = $entityName[0]; |
| 55 | 55 | $this->entityAlias = $entityAlias; |
| 56 | 56 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | foreach ($orFilters as $key => $filter) { |
| 133 | 133 | if (is_array($filter)) { |
| 134 | 134 | foreach ($filter as $keyInternal => $internal) { |
| 135 | - $filterOrCorrected[$keyInternal .'|' . $count] = $internal; |
|
| 135 | + $filterOrCorrected[$keyInternal . '|' . $count] = $internal; |
|
| 136 | 136 | $count = $count + 1; |
| 137 | 137 | } |
| 138 | 138 | } else { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | foreach ($orFilters as $key => $filter) { |
| 185 | 185 | if (is_array($filter)) { |
| 186 | 186 | foreach ($filter as $keyInternal => $internal) { |
| 187 | - $filterOrCorrected[$keyInternal .'|' . $count] = $internal; |
|
| 187 | + $filterOrCorrected[$keyInternal . '|' . $count] = $internal; |
|
| 188 | 188 | $count = $count + 1; |
| 189 | 189 | } |
| 190 | 190 | } else { |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | foreach ($orFilters as $key => $filter) { |
| 232 | 232 | if (is_array($filter)) { |
| 233 | 233 | foreach ($filter as $keyInternal => $internal) { |
| 234 | - $filterOrCorrected[$keyInternal .'|' . $count] = $internal; |
|
| 234 | + $filterOrCorrected[$keyInternal . '|' . $count] = $internal; |
|
| 235 | 235 | $count = $count + 1; |
| 236 | 236 | } |
| 237 | 237 | } else { |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $pagerAdapter = new DoctrineORMAdapter($queryBuilder); |
| 289 | 289 | |
| 290 | 290 | $query = $pagerAdapter->getQuery(); |
| 291 | - if(isset($this->use_result_cache) and $this->use_result_cache){ |
|
| 291 | + if (isset($this->use_result_cache) and $this->use_result_cache) { |
|
| 292 | 292 | $query->useResultCache(true, 600); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $params[$itemValue] = $this->queryOptions->get($itemValue); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if(!isset($this->route_name)){ |
|
| 330 | + if (!isset($this->route_name)) { |
|
| 331 | 331 | $this->route_name = $this->queryOptions->get('_route'); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | public function noExistsJoin($prevEntityAlias, $currentEntityAlias) |
| 339 | 339 | { |
| 340 | 340 | $needle = $prevEntityAlias . "_" . $currentEntityAlias; |
| 341 | - return ! in_array($needle, $this->joins); |
|
| 341 | + return !in_array($needle, $this->joins); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** @deprecate use QueryBuilderFatory instead */ |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | public function getEntityAlias(string $entityName) : string |
| 448 | 448 | { |
| 449 | - $arrayEntityName = explode('\\', strtolower($entityName) ); |
|
| 450 | - $entityAlias = $arrayEntityName[count($arrayEntityName)-1]; |
|
| 449 | + $arrayEntityName = explode('\\', strtolower($entityName)); |
|
| 450 | + $entityAlias = $arrayEntityName[count($arrayEntityName) - 1]; |
|
| 451 | 451 | return $entityAlias; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -532,16 +532,16 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | $table = $this->getEntityManager()->getClassMetadata($this->getEntityName())->getTableName(); |
| 534 | 534 | |
| 535 | - $sql = 'INSERT INTO '.$table; |
|
| 536 | - $sql .= '('. $list_keys . ') '; |
|
| 535 | + $sql = 'INSERT INTO ' . $table; |
|
| 536 | + $sql .= '(' . $list_keys . ') '; |
|
| 537 | 537 | //$sql .= 'VALUES("'.implode('","', $insertFields).'") '; |
| 538 | - $sql .= "VALUES(". $list_values.") "; |
|
| 538 | + $sql .= "VALUES(" . $list_values . ") "; |
|
| 539 | 539 | $sql .= 'ON DUPLICATE KEY UPDATE '; |
| 540 | 540 | |
| 541 | 541 | $c = 0; |
| 542 | - foreach($updateFields as $column => $value) { |
|
| 543 | - if($c>0)$sql .= ", "; |
|
| 544 | - $sql .= '`'.$column . "` = '". $value."'"; |
|
| 542 | + foreach ($updateFields as $column => $value) { |
|
| 543 | + if ($c > 0)$sql .= ", "; |
|
| 544 | + $sql .= '`' . $column . "` = '" . $value . "'"; |
|
| 545 | 545 | $c++; |
| 546 | 546 | } |
| 547 | 547 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $configuration = new Configuration(); |
| 23 | 23 | $config = $this->processConfiguration($configuration, $configs); |
| 24 | 24 | |
| 25 | - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 25 | + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
| 26 | 26 | $loader->load('services.yml'); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $needle = $prevEntityAlias . "_" . $currentEntityAlias; |
| 109 | 109 | |
| 110 | - return ! in_array($needle, $this->joins); |
|
| 110 | + return !in_array($needle, $this->joins); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | private function storeJoin($prevEntityAlias, $currentEntityAlias) |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | private function applyFilterAnd($filter, $value) |
| 214 | 214 | { |
| 215 | 215 | $whereCondition = null; |
| 216 | - $filterAndOperator = explode('|',$filter); |
|
| 216 | + $filterAndOperator = explode('|', $filter); |
|
| 217 | 217 | |
| 218 | 218 | $fieldName = $filterAndOperator[0]; |
| 219 | 219 | $fieldName = $this->parser->camelize($fieldName); |
| 220 | 220 | |
| 221 | 221 | $operator = $this->getValueAvailableFilters()[self::DEFAULT_OPERATOR]; |
| 222 | - if(isset($filterAndOperator[1])){ |
|
| 222 | + if (isset($filterAndOperator[1])) { |
|
| 223 | 223 | $operator = $this->getValueAvailableFilters()[$filterAndOperator[1]]; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | // $filterAndOperator[1] = 'bar' |
| 240 | 240 | if (isset($filterAndOperator[1])) { |
| 241 | 241 | if ('list' == $filterAndOperator[1]) { |
| 242 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' (:field_'.$fieldName . $salt . ')'; |
|
| 242 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' (:field_' . $fieldName . $salt . ')'; |
|
| 243 | 243 | } else if ('field_eq' == $filterAndOperator[1]) { |
| 244 | 244 | $whereCondition = |
| 245 | - $this->entityAlias . '.' . $fieldName . ' '. |
|
| 245 | + $this->entityAlias . '.' . $fieldName . ' ' . |
|
| 246 | 246 | $operator['meta'] . '' . |
| 247 | 247 | $this->entityAlias . '.' . $value |
| 248 | 248 | ; |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | //'Oops! Eccezzione' |
| 252 | 252 | //); |
| 253 | 253 | } else { |
| 254 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' :field_'.$fieldName . $salt; |
|
| 254 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' :field_' . $fieldName . $salt; |
|
| 255 | 255 | } |
| 256 | 256 | } else { |
| 257 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' = :field_'.$fieldName . $salt; |
|
| 257 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' = :field_' . $fieldName . $salt; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $this->qBuilder->andWhere($whereCondition); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | } else { |
| 276 | 276 | $isNotARelation = 0 !== strpos($fieldName, 'Embedded.'); |
| 277 | 277 | if ($isNotARelation) { |
| 278 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' ' . $this->entityAlias . '.' . $value; |
|
| 278 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' ' . $this->entityAlias . '.' . $value; |
|
| 279 | 279 | $this->qBuilder->andWhere($whereCondition); |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $relationEntityAlias = $this->getRelationEntityAlias(); |
| 289 | 289 | |
| 290 | 290 | $embeddedFields = explode('.', $fieldName); |
| 291 | - $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields)-1]); |
|
| 291 | + $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields) - 1]); |
|
| 292 | 292 | |
| 293 | 293 | $salt = ''; |
| 294 | 294 | foreach ($this->qBuilder->getParameters() as $parameter) { |
@@ -298,9 +298,9 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if (isset($filterAndOperator[1]) && 'list' == $filterAndOperator[1]) { |
| 301 | - $whereCondition = $relationEntityAlias.'.'.$fieldName.' '.$operator['meta'].' (:field_'.$fieldName . $salt . ')'; |
|
| 301 | + $whereCondition = $relationEntityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' (:field_' . $fieldName . $salt . ')'; |
|
| 302 | 302 | } else { |
| 303 | - $whereCondition = $relationEntityAlias.'.'.$fieldName.' '.$operator['meta'].' :field_'.$fieldName . $salt; |
|
| 303 | + $whereCondition = $relationEntityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' :field_' . $fieldName . $salt; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $this->qBuilder->andWhere($whereCondition); |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | private function applyFilterOr($filter, $value, $orCondition) |
| 324 | 324 | { |
| 325 | 325 | $whereCondition = null; |
| 326 | - $filterAndOperator = explode('|',$filter); |
|
| 326 | + $filterAndOperator = explode('|', $filter); |
|
| 327 | 327 | |
| 328 | 328 | $fieldName = $filterAndOperator[0]; |
| 329 | 329 | $fieldName = $this->parser->camelize($fieldName); |
| 330 | 330 | |
| 331 | 331 | $operator = $this->getValueAvailableFilters()[self::DEFAULT_OPERATOR]; |
| 332 | - if(isset($filterAndOperator[1])){ |
|
| 332 | + if (isset($filterAndOperator[1])) { |
|
| 333 | 333 | $operator = $this->getValueAvailableFilters()[$filterAndOperator[1]]; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -353,10 +353,10 @@ discard block |
||
| 353 | 353 | // $filterAndOperator[1] = 'bar' |
| 354 | 354 | if (isset($filterAndOperator[1])) { |
| 355 | 355 | if ('list' == $filterAndOperator[1]) { |
| 356 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' (:field_'.$fieldName . $salt . ')'; |
|
| 356 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' (:field_' . $fieldName . $salt . ')'; |
|
| 357 | 357 | } else if ('field_eq' == $filterAndOperator[1]) { |
| 358 | 358 | $whereCondition = |
| 359 | - $this->entityAlias . '.' . $fieldName . ' '. |
|
| 359 | + $this->entityAlias . '.' . $fieldName . ' ' . |
|
| 360 | 360 | $operator['meta'] . '' . |
| 361 | 361 | $this->entityAlias . '.' . $value |
| 362 | 362 | ; |
@@ -365,10 +365,10 @@ discard block |
||
| 365 | 365 | //'Oops! Eccezzione' |
| 366 | 366 | //); |
| 367 | 367 | } else { |
| 368 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' :field_'.$fieldName . $salt; |
|
| 368 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' :field_' . $fieldName . $salt; |
|
| 369 | 369 | } |
| 370 | 370 | } else { |
| 371 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' = :field_'.$fieldName . $salt; |
|
| 371 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' = :field_' . $fieldName . $salt; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | if ($orCondition['orCondition'] != null) { |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | } else { |
| 397 | 397 | $isNotARelation = 0 !== strpos($fieldName, 'Embedded.'); |
| 398 | 398 | if ($isNotARelation) { |
| 399 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' ' . $this->entityAlias . '.' . $value; |
|
| 399 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' ' . $this->entityAlias . '.' . $value; |
|
| 400 | 400 | if ($orCondition['orCondition'] != null) { |
| 401 | 401 | $orCondition['orCondition'] .= ' OR ' . $whereCondition; |
| 402 | 402 | } else { |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $relationEntityAlias = $this->getRelationEntityAlias(); |
| 414 | 414 | |
| 415 | 415 | $embeddedFields = explode('.', $fieldName); |
| 416 | - $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields)-1]); |
|
| 416 | + $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields) - 1]); |
|
| 417 | 417 | |
| 418 | 418 | $salt = ''; |
| 419 | 419 | foreach ($this->qBuilder->getParameters() as $parameter) { |
@@ -427,9 +427,9 @@ discard block |
||
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | if (isset($filterAndOperator[1]) && 'list' == $filterAndOperator[1]) { |
| 430 | - $whereCondition = $relationEntityAlias.'.'.$fieldName.' '.$operator['meta'].' (:field_'.$fieldName . $salt . ')'; |
|
| 430 | + $whereCondition = $relationEntityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' (:field_' . $fieldName . $salt . ')'; |
|
| 431 | 431 | } else { |
| 432 | - $whereCondition = $relationEntityAlias.'.'.$fieldName.' '.$operator['meta'].' :field_'.$fieldName . $salt; |
|
| 432 | + $whereCondition = $relationEntityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' :field_' . $fieldName . $salt; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | if ($orCondition['orCondition'] != null) { |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | if (in_array($fieldName, $this->fields)) { |
| 482 | 482 | $direction = ($val === self::DIRECTION_AZ) ? self::DIRECTION_AZ : self::DIRECTION_ZA; |
| 483 | - $this->qBuilder->addOrderBy($this->entityAlias .'.'. $fieldName, $direction); |
|
| 483 | + $this->qBuilder->addOrderBy($this->entityAlias . '.' . $fieldName, $direction); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | if (strstr($sort, '_embedded.')) { |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | $fieldName = $this->parser->camelize($embeddedFields[2]); |
| 492 | 492 | $direction = ($val === self::DIRECTION_AZ) ? self::DIRECTION_AZ : self::DIRECTION_ZA; |
| 493 | 493 | |
| 494 | - $this->qBuilder->addOrderBy($relationEntityAlias.'.'.$fieldName, $direction); |
|
| 494 | + $this->qBuilder->addOrderBy($relationEntityAlias . '.' . $fieldName, $direction); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | return $this->pageLength; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - public function setSelect( $select) : QueryBuilderFactory |
|
| 582 | + public function setSelect($select) : QueryBuilderFactory |
|
| 583 | 583 | { |
| 584 | 584 | $this->select = $select; |
| 585 | 585 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | 'path' => __DIR__ . '/../../data/db.sqlite', |
| 16 | 16 | ), |
| 17 | 17 | \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration( |
| 18 | - array(__DIR__."/src"), |
|
| 18 | + array(__DIR__ . "/src"), |
|
| 19 | 19 | true |
| 20 | 20 | )); |
| 21 | 21 | } |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | public function testProvideOneSingleResult() |
| 24 | 24 | { |
| 25 | 25 | $queryBuilderFactory = new QueryBuilderFactory($this->manager); |
| 26 | - $queryBuilderFactory->setFields([ 'id' ]); |
|
| 27 | - $queryBuilderFactory->setFilters([ 'id|eq' => 33 ]); |
|
| 26 | + $queryBuilderFactory->setFields(['id']); |
|
| 27 | + $queryBuilderFactory->setFilters(['id|eq' => 33]); |
|
| 28 | 28 | $queryBuilderFactory->createQueryBuilder(MySimpleEntity::class, 'e'); |
| 29 | 29 | $queryBuilderFactory->filter(); |
| 30 | 30 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | public function testSampleQueryMakedWithQueryBuilderFactory() |
| 41 | 41 | { |
| 42 | 42 | $queryBuilderFactory = new QueryBuilderFactory($this->manager); |
| 43 | - $queryBuilderFactory->setFields([ 'id' ]); |
|
| 44 | - $queryBuilderFactory->setFilters([ 'id|eq' => 33 ]); |
|
| 43 | + $queryBuilderFactory->setFields(['id']); |
|
| 44 | + $queryBuilderFactory->setFilters(['id|eq' => 33]); |
|
| 45 | 45 | $queryBuilderFactory->createQueryBuilder(MySimpleEntity::class, 'e'); |
| 46 | 46 | $queryBuilderFactory->filter(); |
| 47 | 47 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | public function testOneToManyQueryMakedHandly() |
| 60 | 60 | { |
| 61 | 61 | $queryBuilderFactory = new QueryBuilderFactory($this->manager); |
| 62 | - $queryBuilderFactory->setFields([ 'id' ]); |
|
| 63 | - $queryBuilderFactory->setRel([ 'group' ]); |
|
| 62 | + $queryBuilderFactory->setFields(['id']); |
|
| 63 | + $queryBuilderFactory->setRel(['group']); |
|
| 64 | 64 | $queryBuilderFactory->setFilters([ |
| 65 | 65 | '_embedded.group.name|contains|1' => 'ad', |
| 66 | 66 | '_embedded.group.name|contains|2' => 'ns', |