@@ -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 | } |
@@ -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', |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | ->getMock(); |
| 48 | 48 | $this->factory->expects($this->once()) |
| 49 | 49 | ->method('getAllMetadata') |
| 50 | - ->will($this->returnValue(function () { |
|
| 50 | + ->will($this->returnValue(function() { |
|
| 51 | 51 | return [ |
| 52 | 52 | 'SomeBundle\Entity\ParentEntity' => [ |
| 53 | 53 | 'relations' => [ |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $this->mapper = $mapper; |
| 47 | 47 | $this->logger = $logger; |
| 48 | 48 | |
| 49 | - $this->appendRootEntityToSubject = function($subject, $rootEntity) { |
|
| 49 | + $this->appendRootEntityToSubject = function($subject, $rootEntity) { |
|
| 50 | 50 | $subject[] = $rootEntity; |
| 51 | 51 | return $subject; |
| 52 | 52 | }; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $entities = $this->getEntitiesPath(); |
| 277 | 277 | $lastEntityFound = end($entities); |
| 278 | 278 | $this->removeStep($lastEntityFound); |
| 279 | - } catch(\Mado\QueryBundle\Component\Meta\Exceptions\UnexpectedValueException $e) { |
|
| 279 | + } catch (\Mado\QueryBundle\Component\Meta\Exceptions\UnexpectedValueException $e) { |
|
| 280 | 280 | return; |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | $needle = $prevEntityAlias . "_" . $currentEntityAlias; |
| 106 | 106 | |
| 107 | - return ! in_array($needle, $this->joins); |
|
| 107 | + return !in_array($needle, $this->joins); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | private function storeJoin($prevEntityAlias, $currentEntityAlias) |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | Objects\Value $filterValue |
| 216 | 216 | ) { |
| 217 | 217 | $whereCondition = null; |
| 218 | - $filterAndOperator = explode('|',$filter); |
|
| 218 | + $filterAndOperator = explode('|', $filter); |
|
| 219 | 219 | |
| 220 | 220 | if (!isset($filterAndOperator[1])) { |
| 221 | 221 | $filterAndOperator[1] = 'eq'; |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $fieldName = $this->parser->camelize($fieldName); |
| 227 | 227 | |
| 228 | 228 | $operator = $this->getValueAvailableFilters()[self::DEFAULT_OPERATOR]; |
| 229 | - if(isset($filterAndOperator[1])){ |
|
| 229 | + if (isset($filterAndOperator[1])) { |
|
| 230 | 230 | $operator = $this->getValueAvailableFilters()[$filterAndOperator[1]]; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | . ' (:field_' . $fieldName . $salt . ')'; |
| 251 | 251 | } else if ('field_eq' == $filterAndOperator[1]) { |
| 252 | 252 | $whereCondition = |
| 253 | - $this->entityAlias . '.' . $fieldName . ' '. |
|
| 253 | + $this->entityAlias . '.' . $fieldName . ' ' . |
|
| 254 | 254 | $operator['meta'] . '' . |
| 255 | 255 | $this->entityAlias . '.' . $value |
| 256 | 256 | ; |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | //'Oops! Eccezzione' |
| 260 | 260 | //); |
| 261 | 261 | } else { |
| 262 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' :field_'.$fieldName . $salt; |
|
| 262 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' :field_' . $fieldName . $salt; |
|
| 263 | 263 | } |
| 264 | 264 | } else { |
| 265 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' = :field_'.$fieldName . $salt; |
|
| 265 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' = :field_' . $fieldName . $salt; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | $this->qBuilder->andWhere($whereCondition); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $relationEntityAlias = $this->getRelationEntityAlias(); |
| 297 | 297 | |
| 298 | 298 | $embeddedFields = explode('.', $fieldName); |
| 299 | - $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields)-1]); |
|
| 299 | + $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields) - 1]); |
|
| 300 | 300 | |
| 301 | 301 | $salt = ''; |
| 302 | 302 | foreach ($this->qBuilder->getParameters() as $parameter) { |
@@ -335,14 +335,14 @@ discard block |
||
| 335 | 335 | private function applyFilterOr($filter, $value, $orCondition) |
| 336 | 336 | { |
| 337 | 337 | $whereCondition = null; |
| 338 | - $filterAndOperator = explode('|',$filter); |
|
| 338 | + $filterAndOperator = explode('|', $filter); |
|
| 339 | 339 | $op = Objects\Operator::fromString($filterAndOperator[1]); |
| 340 | 340 | |
| 341 | 341 | $fieldName = $filterAndOperator[0]; |
| 342 | 342 | $fieldName = $this->parser->camelize($fieldName); |
| 343 | 343 | |
| 344 | 344 | $operator = $this->getValueAvailableFilters()[self::DEFAULT_OPERATOR]; |
| 345 | - if(isset($filterAndOperator[1])){ |
|
| 345 | + if (isset($filterAndOperator[1])) { |
|
| 346 | 346 | $operator = $this->getValueAvailableFilters()[$filterAndOperator[1]]; |
| 347 | 347 | } |
| 348 | 348 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | . ' (:field_' . $fieldName . $salt . ')'; |
| 372 | 372 | } else if ('field_eq' == $filterAndOperator[1]) { |
| 373 | 373 | $whereCondition = |
| 374 | - $this->entityAlias . '.' . $fieldName . ' '. |
|
| 374 | + $this->entityAlias . '.' . $fieldName . ' ' . |
|
| 375 | 375 | $operator['meta'] . '' . |
| 376 | 376 | $this->entityAlias . '.' . $value |
| 377 | 377 | ; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | . ' :field_' . $fieldName . $salt; |
| 386 | 386 | } |
| 387 | 387 | } else { |
| 388 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' = :field_'.$fieldName . $salt; |
|
| 388 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' = :field_' . $fieldName . $salt; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | if ($orCondition['orCondition'] != null) { |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | } else { |
| 414 | 414 | $isNotARelation = 0 !== strpos($fieldName, 'Embedded.'); |
| 415 | 415 | if ($isNotARelation) { |
| 416 | - $whereCondition = $this->entityAlias.'.'.$fieldName.' '.$operator['meta'].' ' . $this->entityAlias . '.' . $value; |
|
| 416 | + $whereCondition = $this->entityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' ' . $this->entityAlias . '.' . $value; |
|
| 417 | 417 | if ($orCondition['orCondition'] != null) { |
| 418 | 418 | $orCondition['orCondition'] .= ' OR ' . $whereCondition; |
| 419 | 419 | } else { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | $relationEntityAlias = $this->getRelationEntityAlias(); |
| 431 | 431 | |
| 432 | 432 | $embeddedFields = explode('.', $fieldName); |
| 433 | - $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields)-1]); |
|
| 433 | + $fieldName = $this->parser->camelize($embeddedFields[count($embeddedFields) - 1]); |
|
| 434 | 434 | |
| 435 | 435 | $salt = ''; |
| 436 | 436 | foreach ($this->qBuilder->getParameters() as $parameter) { |
@@ -444,9 +444,9 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | if (isset($filterAndOperator[1]) && $op->isListOrNlist()) { |
| 447 | - $whereCondition = $relationEntityAlias.'.'.$fieldName.' '.$operator['meta'].' (:field_'.$fieldName . $salt . ')'; |
|
| 447 | + $whereCondition = $relationEntityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' (:field_' . $fieldName . $salt . ')'; |
|
| 448 | 448 | } else { |
| 449 | - $whereCondition = $relationEntityAlias.'.'.$fieldName.' '.$operator['meta'].' :field_'.$fieldName . $salt; |
|
| 449 | + $whereCondition = $relationEntityAlias . '.' . $fieldName . ' ' . $operator['meta'] . ' :field_' . $fieldName . $salt; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | if ($orCondition['orCondition'] != null) { |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | if (in_array($fieldName, $this->fields)) { |
| 499 | 499 | $direction = ($val === self::DIRECTION_AZ) ? self::DIRECTION_AZ : self::DIRECTION_ZA; |
| 500 | - $this->qBuilder->addOrderBy($this->entityAlias .'.'. $fieldName, $direction); |
|
| 500 | + $this->qBuilder->addOrderBy($this->entityAlias . '.' . $fieldName, $direction); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | if (strstr($sort, '_embedded.')) { |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | $fieldName = $this->parser->camelize($embeddedFields[2]); |
| 509 | 509 | $direction = ($val === self::DIRECTION_AZ) ? self::DIRECTION_AZ : self::DIRECTION_ZA; |
| 510 | 510 | |
| 511 | - $this->qBuilder->addOrderBy($relationEntityAlias.'.'.$fieldName, $direction); |
|
| 511 | + $this->qBuilder->addOrderBy($relationEntityAlias . '.' . $fieldName, $direction); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | return $this->pageLength; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - public function setSelect( $select) : QueryBuilderFactory |
|
| 599 | + public function setSelect($select) : QueryBuilderFactory |
|
| 600 | 600 | { |
| 601 | 601 | $this->select = $select; |
| 602 | 602 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $this->fields = array_keys($this->getClassMetadata()->fieldMappings); |
| 42 | 42 | |
| 43 | - $entityName = explode('\\', strtolower($this->getEntityName()) ); |
|
| 44 | - $entityName = $entityName[count($entityName)-1]; |
|
| 43 | + $entityName = explode('\\', strtolower($this->getEntityName())); |
|
| 44 | + $entityName = $entityName[count($entityName) - 1]; |
|
| 45 | 45 | $entityAlias = $entityName[0]; |
| 46 | 46 | $this->entityAlias = $entityAlias; |
| 47 | 47 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | foreach ($orFilters as $key => $filter) { |
| 123 | 123 | if (is_array($filter)) { |
| 124 | 124 | foreach ($filter as $keyInternal => $internal) { |
| 125 | - $filterOrCorrected[$keyInternal .'|' . $count] = $internal; |
|
| 125 | + $filterOrCorrected[$keyInternal . '|' . $count] = $internal; |
|
| 126 | 126 | $count += 1; |
| 127 | 127 | } |
| 128 | 128 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | foreach ($orFilters as $key => $filterValue) { |
| 174 | 174 | if (is_array($filterValue)) { |
| 175 | 175 | foreach ($filterValue as $keyInternal => $internal) { |
| 176 | - $filterOrCorrected[$keyInternal .'|' . $count] = $internal; |
|
| 176 | + $filterOrCorrected[$keyInternal . '|' . $count] = $internal; |
|
| 177 | 177 | $count += 1; |
| 178 | 178 | } |
| 179 | 179 | } else { |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | foreach ($orFilters as $key => $filter) { |
| 220 | 220 | if (\is_array($filter)) { |
| 221 | 221 | foreach ($filter as $keyInternal => $internal) { |
| 222 | - $filterOrCorrected[$keyInternal .'|' . $count] = $internal; |
|
| 222 | + $filterOrCorrected[$keyInternal . '|' . $count] = $internal; |
|
| 223 | 223 | $count += 1; |
| 224 | 224 | } |
| 225 | 225 | } else { |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $pagerAdapter = new DoctrineORMAdapter($queryBuilder); |
| 274 | 274 | |
| 275 | 275 | $query = $pagerAdapter->getQuery(); |
| 276 | - if(null != $this->use_result_cache && $this->use_result_cache){ |
|
| 276 | + if (null != $this->use_result_cache && $this->use_result_cache) { |
|
| 277 | 277 | $query->useResultCache(true, 600); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | $params[$itemValue] = $this->queryOptions->get($itemValue); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if(!isset($this->route_name)){ |
|
| 312 | + if (!isset($this->route_name)) { |
|
| 313 | 313 | $this->route_name = $this->queryOptions->get('_route'); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -338,8 +338,8 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | public function getEntityAlias(string $entityName) : string |
| 340 | 340 | { |
| 341 | - $arrayEntityName = explode('\\', strtolower($entityName) ); |
|
| 342 | - return $arrayEntityName[count($arrayEntityName)-1]; |
|
| 341 | + $arrayEntityName = explode('\\', strtolower($entityName)); |
|
| 342 | + return $arrayEntityName[count($arrayEntityName) - 1]; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | protected function relationship($queryBuilder) |