Draft commit with POC

This commit is contained in:
Matej Baco committed 2021-12-30 10:25:43 +01:00
1 parent b05680cf7d
commit 9b749db89b
5 files changed
+95 -25

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
<?php
namespace Appwrite\Utopia\Request;
abstract class Filter
{
/**
* Parse params to another format.
*
* @param array $content
* @param string $model
*
* @return array
*/
abstract public function parse(array $content, string $model): array;
}
@@ -0,0 +1,35 @@
<?php
namespace Appwrite\Utopia\Request\Filters;
use Appwrite\Utopia\Request\Filter;
class V11 extends Filter
{
// TODO: Should this class be called be V11 or V12?
// Convert 0.11 params format to 0.12 format
public function parse(array $content, string $model): array
{
$parsedResponse = [];
switch ($model) {
case "account.create":
$parsedResponse = $this->addUserId($content);
break;
}
if(empty($parsedResponse)) {
// TODO: Do we need execption? We dont need to find, right? Not found means no changes
// throw new Exception('Received invalid request model : '. $model);
$parsedResponse = $content;
}
return $parsedResponse;
}
protected function addUserId(array $content): array
{
$content['userId'] = 'unique()';
return $content;
}
}