2020-11-12 11:02:42 +13:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Specification;
|
|
|
|
|
|
|
|
use Utopia\App;
|
|
|
|
use Utopia\Route;
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
abstract class Format
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var App
|
|
|
|
*/
|
|
|
|
protected $app;
|
|
|
|
|
2021-01-27 00:54:06 +13:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $services;
|
|
|
|
|
2020-11-12 11:02:42 +13:00
|
|
|
/**
|
|
|
|
* @var Route[]
|
|
|
|
*/
|
|
|
|
protected $routes;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Model[]
|
|
|
|
*/
|
|
|
|
protected $models;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $keys;
|
|
|
|
|
2021-05-20 02:26:06 +12:00
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $authCount;
|
|
|
|
|
2020-11-12 11:02:42 +13:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $params = [
|
|
|
|
'name' => '',
|
|
|
|
'description' => '',
|
|
|
|
'endpoint' => 'https://localhost',
|
|
|
|
'version' => '1.0.0',
|
|
|
|
'terms' => '',
|
|
|
|
'support.email' => '',
|
|
|
|
'support.url' => '',
|
|
|
|
'contact.name' => '',
|
|
|
|
'contact.email' => '',
|
|
|
|
'contact.url' => '',
|
|
|
|
'license.name' => '',
|
|
|
|
'license.url' => '',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param App $app
|
2021-01-27 00:54:06 +13:00
|
|
|
* @param array $services
|
2020-11-12 11:02:42 +13:00
|
|
|
* @param Route[] $routes
|
|
|
|
* @param Model[] $models
|
|
|
|
* @param array $keys
|
2021-06-02 00:13:44 +12:00
|
|
|
* @param int $authCount
|
2020-11-12 11:02:42 +13:00
|
|
|
*/
|
2021-06-03 21:58:59 +12:00
|
|
|
public function __construct(App $app, array $services, array $routes, array $models, array $keys, int $authCount)
|
2020-11-12 11:02:42 +13:00
|
|
|
{
|
|
|
|
$this->app = $app;
|
2021-01-27 00:54:06 +13:00
|
|
|
$this->services = $services;
|
2020-11-12 11:02:42 +13:00
|
|
|
$this->routes = $routes;
|
|
|
|
$this->models = $models;
|
|
|
|
$this->keys = $keys;
|
2021-05-20 02:26:06 +12:00
|
|
|
$this->authCount = $authCount;
|
2020-11-12 11:02:42 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Name.
|
|
|
|
*
|
|
|
|
* Get format name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function getName(): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse
|
|
|
|
*
|
|
|
|
* Parses Appwrite App to given format
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
abstract public function parse(): array;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Param.
|
|
|
|
*
|
|
|
|
* Set param value
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @param string $value
|
|
|
|
*
|
|
|
|
* @return self
|
|
|
|
*/
|
|
|
|
public function setParam(string $key, string $value): self
|
|
|
|
{
|
|
|
|
$this->params[$key] = $value;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Param.
|
|
|
|
*
|
|
|
|
* Get param value
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @param string $default
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getParam(string $key, string $default = ''): string
|
|
|
|
{
|
|
|
|
if(!isset($this->params[$key])) {
|
|
|
|
return $default;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->params[$key];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|