mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Fix vars exception, change cachedoc usage,
This commit is contained in:
@@ -65,7 +65,7 @@ class Func extends Model
|
||||
'type' => Response::MODEL_VARIABLE,
|
||||
'description' => 'Function environment variables.',
|
||||
'default' => [],
|
||||
'example' => new \stdClass(),
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('events', [
|
||||
@@ -121,25 +121,4 @@ class Func extends Model
|
||||
{
|
||||
return Response::MODEL_FUNCTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Function
|
||||
*
|
||||
* Automatically converts a [] default to a stdClass, this is called while grabbing the document.
|
||||
*
|
||||
* @param Document $document
|
||||
* @return Document
|
||||
*/
|
||||
public function filter(Document $document): Document
|
||||
{
|
||||
$vars = $document->getAttribute('vars');
|
||||
if ($vars instanceof Document) {
|
||||
$vars = $vars->getArrayCopy();
|
||||
}
|
||||
|
||||
if (is_array($vars) && empty($vars)) {
|
||||
$document->setAttribute('vars', new stdClass());
|
||||
}
|
||||
return $document;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user