Skip to content

Commit

Permalink
grid: support sorting by object brick quantity value field
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackbitDevs committed Sep 17, 2024
1 parent d78819c commit 25fb6f7
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Helper/GridHelperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,20 @@ public function prepareListingForGrid(array $requestParams, string $requestedLan
$orderKey = 'concat(' . $orderKey . '__rgb, ' . $orderKey . '__a)';
$doNotQuote = true;
} elseif (strpos($orderKey, '~') !== false) {
$orderKeyParts = explode('~', $orderKey);
$orderKey = $list->quoteIdentifier($orderKeyParts[0]).'.'.$list->quoteIdentifier($orderKeyParts[1]);

Check failure on line 569 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 569 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 569 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 569 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 569 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 569 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

if (strpos($orderKey, '?') !== false) {
$brickDescriptor = substr($orderKeyParts[0], 1);
$brickDescriptor = json_decode($brickDescriptor, true);
$orderKey = $list->quoteIdentifier($brickDescriptor['containerKey'] . '_localized')
. '.' . $list->quoteIdentifier($brickDescriptor['brickfield']);
$doNotQuote = true;
} elseif (count($orderKeyParts) === 2) {
$orderKey = $list->quoteIdentifier($orderKeyParts[0])
. '.' . $list->quoteIdentifier($orderKeyParts[1]);
$doNotQuote = true;
$brickDefinition = Objectbrick\Definition::getByKey($orderKeyParts[0]);

Check failure on line 571 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 571 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 571 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts
if ($brickDefinition instanceof Objectbrick\Definition) {
$brickFieldDefinition = $brickDefinition->getFieldDefinition($orderKeyParts[1]);

Check failure on line 573 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 573 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 573 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

if ($brickFieldDefinition instanceof ClassDefinition\Data\QuantityValue) {
$orderKey = 'CONCAT('.$list->quoteIdentifier($orderKeyParts[0]).'.'.$list->quoteIdentifier($orderKeyParts[1].'__unit').', '.$list->quoteIdentifier($orderKeyParts[0]).'.'.$list->quoteIdentifier($orderKeyParts[1].'__value').')';

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 576 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts
} elseif ($brickFieldDefinition instanceof ClassDefinition\Data\RgbaColor) {
$orderKey = 'CONCAT('.$list->quoteIdentifier($orderKeyParts[0]).'.'.$list->quoteIdentifier($orderKeyParts[1].'__rgb').', '.$list->quoteIdentifier($orderKeyParts[0]).'.'.$list->quoteIdentifier($orderKeyParts[1].'__a').')';

Check failure on line 578 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 578 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.1, lowest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 578 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 578 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 578 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts

Check failure on line 578 in src/Helper/GridHelperService.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Undefined variable: $orderKeyParts
}
}

$doNotQuote = true;
} else {
$orderKey = $list->getDao()->getTableName() . '.' . $list->quoteIdentifier($orderKey);
$doNotQuote = true;
Expand Down

0 comments on commit 25fb6f7

Please sign in to comment.