Skip to content

Commit

Permalink
Fix MassiveSearchExpressionLanguage with object/stdClass for block se…
Browse files Browse the repository at this point in the history
…ttings (#175)
  • Loading branch information
popoplanter authored Feb 8, 2024
1 parent 2c74782 commit 3d1b065
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Search/ExpressionLanguage/MassiveSearchExpressionLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException;
use Symfony\Component\PropertyAccess\PropertyAccessor;

/**
Expand Down Expand Up @@ -104,9 +105,15 @@ function($elements, $expression) {
throw new \Exception('Value function does not support compilation');
},
function(array $values, $propertyPath, $default = null) use ($accessor) {
$value = $accessor->getValue($values, $propertyPath);
if (null !== $value) {
return $value;
try {
$value = $accessor->getValue($values, $propertyPath);
if (null !== $value) {
return $value;
}
} catch (NoSuchIndexException $e) {
// settings can be stdClass as it needs to convert to {} instead of [] for frontend
// currently NoSuchIndexException will be thrown which we need to catch here and
// return the default value
}

return $default;
Expand Down

0 comments on commit 3d1b065

Please sign in to comment.