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 = '';
|
|
|
|
|
2020-11-12 18:12:14 +13:00
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
* @param string $type
|
|
|
|
* @param string $key
|
|
|
|
* @param string $model
|
|
|
|
* @param bool $paging
|
|
|
|
* @param bool $public
|
|
|
|
*/
|
|
|
|
public function __construct(string $name, string $type, string $key, string $model, bool $paging = true, bool $public = true)
|
2020-06-24 17:14:42 +12:00
|
|
|
{
|
2020-10-30 02:07:56 +13:00
|
|
|
$this->name = $name;
|
|
|
|
$this->type = $type;
|
2020-11-12 18:12:14 +13:00
|
|
|
$this->public = $public;
|
2020-10-30 02:07:56 +13:00
|
|
|
|
2020-10-30 11:44:01 +13:00
|
|
|
if ($paging) {
|
2020-10-30 02:07:56 +13:00
|
|
|
$this->addRule('sum', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::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
|
|
|
}
|
|
|
|
}
|