mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Setup request & response filters
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Request\Filters;
|
||||
|
||||
use Appwrite\Utopia\Request\Filter;
|
||||
|
||||
class V19 extends Filter
|
||||
{
|
||||
// Convert 1.6 params to 1.7
|
||||
public function parse(array $content, string $model): array
|
||||
{
|
||||
/*
|
||||
Uncomment with first request filter; current is just a copy of V18
|
||||
switch ($model) {
|
||||
case 'functions.create':
|
||||
$content['something'] = $content['somethingElse'] ?? "";
|
||||
unset($content['something']);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Filters;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Filter;
|
||||
|
||||
class V19 extends Filter
|
||||
{
|
||||
// Convert 1.7 Data format to 1.6 format
|
||||
public function parse(array $content, string $model): array
|
||||
{
|
||||
$parsedResponse = $content;
|
||||
|
||||
$parsedResponse = match($model) {
|
||||
Response::MODEL_FUNCTION => $this->parseFunction($content),
|
||||
Response::MODEL_FUNCTION_LIST => $this->handleList($content, 'functions', fn ($item) => $this->parseFunction($item)),
|
||||
default => $parsedResponse,
|
||||
};
|
||||
|
||||
return $parsedResponse;
|
||||
}
|
||||
|
||||
protected function parseFunction(array $content)
|
||||
{
|
||||
$content['deployment'] = $content['deploymentId'] ?? '';
|
||||
unset($content['deploymentId']);
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user