mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Draft commit with POC
This commit is contained in:
1 parent
b05680cf7d
commit
9b749db89b
5 files changed
+95
-25
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user