mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
Ensure empty team prefs returns as JSON object rather array
This commit is contained in:
parent
e5fa4883b2
commit
bb2b48193f
1 changed files with 19 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ namespace Appwrite\Utopia\Response\Model;
|
|||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\Database\Document;
|
||||
|
||||
class Team extends Model
|
||||
{
|
||||
|
|
@ -49,6 +50,24 @@ class Team extends Model
|
|||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Document before returning it to the client
|
||||
*
|
||||
* @return Document
|
||||
*/
|
||||
public function filter(Document $document): Document
|
||||
{
|
||||
$prefs = $document->getAttribute('prefs');
|
||||
if ($prefs instanceof Document) {
|
||||
$prefs = $prefs->getArrayCopy();
|
||||
}
|
||||
|
||||
if (is_array($prefs) && empty($prefs)) {
|
||||
$document->setAttribute('prefs', new \stdClass());
|
||||
}
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue