Skip to content
Open
Changes from all 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
28 changes: 21 additions & 7 deletions src/Entity/Query/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,30 @@ protected static function matchProperty(array $condition): callable {
* Property value or NULL if not found.
*/
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($property, 'AttributeValue.')) {
[$getter, $attribute_name] = explode('.', $property);
$getter_candidates[] = 'get' . $getter;
unset($getter);
$args = [];
$args[] = $attribute_name;
}
else {
$normalized = ucfirst(implode('', array_map('ucfirst', explode('_', $property))));
$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