| @@ 102-136 (lines=35) @@ | ||
| 99 | * @param array|OrderingPair[] $orderingPairs |
|
| 100 | * @return array|OrderingConfiguration[] |
|
| 101 | */ |
|
| 102 | private function mapToOrderingConfigurations(ConfiguredQuery $configuredQuery, string $rootAlias, array $orderingPairs) |
|
| 103 | { |
|
| 104 | $orderingConfigurations = []; |
|
| 105 | $idIncluded = false; |
|
| 106 | $defaultAscending = null; |
|
| 107 | $orderByIdExpression = sprintf('%s.%s', $rootAlias, self::ID_FIELD); |
|
| 108 | ||
| 109 | foreach ($orderingPairs as $orderingPair) { |
|
| 110 | $orderingConfiguration = $configuredQuery->getOrderingConfigurationFor($orderingPair->getOrderBy()); |
|
| 111 | ||
| 112 | if ($orderingPair->isOrderingDirectionSet()) { |
|
| 113 | $orderingConfiguration->setOrderAscending($orderingPair->isOrderAscending()); |
|
| 114 | } |
|
| 115 | ||
| 116 | if ($orderingConfiguration->getOrderByExpression() === $orderByIdExpression) { |
|
| 117 | $idIncluded = true; |
|
| 118 | } |
|
| 119 | ||
| 120 | if ($defaultAscending === null) { |
|
| 121 | $defaultAscending = $orderingConfiguration->isOrderAscending(); |
|
| 122 | } |
|
| 123 | ||
| 124 | $orderingConfigurations[] = $orderingConfiguration; |
|
| 125 | } |
|
| 126 | ||
| 127 | if ($idIncluded) { |
|
| 128 | return $orderingConfigurations; |
|
| 129 | } |
|
| 130 | ||
| 131 | $orderingConfigurations[] = (new OrderingConfiguration($orderByIdExpression, self::ID_FIELD)) |
|
| 132 | ->setOrderAscending($defaultAscending ?? false) |
|
| 133 | ; |
|
| 134 | ||
| 135 | return $orderingConfigurations; |
|
| 136 | } |
|
| 137 | } |
|
| 138 | ||
| @@ 64-98 (lines=35) @@ | ||
| 61 | * @param array|OrderingPair[] $orderingPairs |
|
| 62 | * @return array|OrderingConfiguration[] |
|
| 63 | */ |
|
| 64 | private function mapToOrderingConfigurations(ConfiguredQuery $configuredQuery, array $orderingPairs) |
|
| 65 | { |
|
| 66 | $orderingConfigurations = []; |
|
| 67 | $idIncluded = false; |
|
| 68 | $defaultAscending = null; |
|
| 69 | $orderByIdExpression = self::ID_FIELD; |
|
| 70 | ||
| 71 | foreach ($orderingPairs as $orderingPair) { |
|
| 72 | $orderingConfiguration = $configuredQuery->getOrderingConfigurationFor($orderingPair->getOrderBy()); |
|
| 73 | ||
| 74 | if ($orderingPair->isOrderingDirectionSet()) { |
|
| 75 | $orderingConfiguration->setOrderAscending($orderingPair->isOrderAscending()); |
|
| 76 | } |
|
| 77 | ||
| 78 | if ($orderingConfiguration->getOrderByExpression() === $orderByIdExpression) { |
|
| 79 | $idIncluded = true; |
|
| 80 | } |
|
| 81 | ||
| 82 | if ($defaultAscending === null) { |
|
| 83 | $defaultAscending = $orderingConfiguration->isOrderAscending(); |
|
| 84 | } |
|
| 85 | ||
| 86 | $orderingConfigurations[] = $orderingConfiguration; |
|
| 87 | } |
|
| 88 | ||
| 89 | if ($idIncluded) { |
|
| 90 | return $orderingConfigurations; |
|
| 91 | } |
|
| 92 | ||
| 93 | $orderingConfigurations[] = (new OrderingConfiguration($orderByIdExpression, self::ID_FIELD)) |
|
| 94 | ->setOrderAscending($defaultAscending ?? false) |
|
| 95 | ; |
|
| 96 | ||
| 97 | return $orderingConfigurations; |
|
| 98 | } |
|
| 99 | } |
|
| 100 | ||