2020-06-24 17:14:42 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
|
|
|
|
2020-10-30 02:07:56 +13:00
|
|
|
class BaseList extends Model
|
2020-06-24 17:14:42 +12:00
|
|
|
{
|
2020-10-30 02:07:56 +13:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $name = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $type = '';
|
|
|
|
|
|
|
|
public function __construct(string $name, string $type, string $key, string $model, bool $paging = true)
|
2020-06-24 17:14:42 +12:00
|
|
|
{
|
2020-10-30 02:07:56 +13:00
|
|
|
$this->name = $name;
|
|
|
|
$this->type = $type;
|
|
|
|
|
|
|
|
if($paging) {
|
|
|
|
$this->addRule('sum', [
|
2020-06-24 18:05:43 +12:00
|
|
|
'type' => 'integer',
|
2020-06-24 17:14:42 +12:00
|
|
|
'description' => 'Total sum of items in the list.',
|
2020-06-24 18:05:43 +12:00
|
|
|
'example' => '5',
|
2020-10-30 02:07:56 +13:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
$this->addRule($key, [
|
|
|
|
'type' => $model,
|
|
|
|
'description' => 'List of '.$key.'.',
|
|
|
|
'example' => [],
|
|
|
|
'array' => true,
|
|
|
|
]);
|
2020-06-24 17:14:42 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName():string
|
|
|
|
{
|
2020-10-30 02:07:56 +13:00
|
|
|
return $this->name;
|
2020-06-24 17:14:42 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Collection
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getType():string
|
|
|
|
{
|
2020-10-30 02:07:56 +13:00
|
|
|
return $this->type;
|
2020-06-24 17:14:42 +12:00
|
|
|
}
|
|
|
|
}
|