Skip to content

Commit 0d4dc51

Browse files
authored
Merge pull request #564 from utopia-php/feat-dump-filter-name
Dump filter + attribute name on filter not found
2 parents 40f72f9 + 0fcd836 commit 0d4dc51

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Database/Database.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6129,7 +6129,7 @@ public function decode(Document $collection, Document $document, array $selectio
61296129

61306130
foreach ($value as &$node) {
61316131
foreach (\array_reverse($filters) as $filter) {
6132-
$node = $this->decodeAttribute($filter, $node, $document);
6132+
$node = $this->decodeAttribute($filter, $node, $document, $key);
61336133
}
61346134
}
61356135

@@ -6246,27 +6246,27 @@ protected function encodeAttribute(string $name, mixed $value, Document $documen
62466246
* Passes the attribute $value, and $document context to a predefined filter
62476247
* that allow you to manipulate the output format of the given attribute.
62486248
*
6249-
* @param string $name
6249+
* @param string $filter
62506250
* @param mixed $value
62516251
* @param Document $document
62526252
*
62536253
* @return mixed
62546254
* @throws DatabaseException
62556255
*/
6256-
protected function decodeAttribute(string $name, mixed $value, Document $document): mixed
6256+
protected function decodeAttribute(string $filter, mixed $value, Document $document, string $attribute): mixed
62576257
{
62586258
if (!$this->filter) {
62596259
return $value;
62606260
}
62616261

6262-
if (!array_key_exists($name, self::$filters) && !array_key_exists($name, $this->instanceFilters)) {
6263-
throw new NotFoundException('Filter not found');
6262+
if (!array_key_exists($filter, self::$filters) && !array_key_exists($filter, $this->instanceFilters)) {
6263+
throw new NotFoundException("Filter \"{$filter}\" not found for attribute \"{$attribute}\"");
62646264
}
62656265

6266-
if (array_key_exists($name, $this->instanceFilters)) {
6267-
$value = $this->instanceFilters[$name]['decode']($value, $document, $this);
6266+
if (array_key_exists($filter, $this->instanceFilters)) {
6267+
$value = $this->instanceFilters[$filter]['decode']($value, $document, $this);
62686268
} else {
6269-
$value = self::$filters[$name]['decode']($value, $document, $this);
6269+
$value = self::$filters[$filter]['decode']($value, $document, $this);
62706270
}
62716271

62726272
return $value;

0 commit comments

Comments
 (0)