Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/Entity/Query/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,29 @@ protected static function matchProperty(array $condition): callable {
*/
public static function getProperty($item, string $property) {
$normalized = ucfirst(implode('', array_map('ucfirst', explode('_', $property))));
$getter_candidates = [
"is{$normalized}",
"get{$normalized}",
$normalized,
];
if (str_starts_with($normalized, 'AttributeValue')) {
[$getter, $attribute_name] = explode('.', $normalized);
$getter_candidates[] = 'get' . $getter;
unset($getter);
$args = [];
$args[] = $attribute_name;
}
else {
$args = NULL;
$getter_candidates = [
"is{$normalized}",
"get{$normalized}",
$normalized,
];
}

foreach ($getter_candidates as $getter) {
if (method_exists($item, $getter)) {
return call_user_func([$item, $getter]);
if ($args === NULL) {
return $item->$getter();
}

return $item->$getter(...$args);
}
}

Expand Down