43 lines
1,012 B
PHP
43 lines
1,012 B
PHP
|
<?php
|
||
|
|
||
|
namespace Appwrite\Response;
|
||
|
|
||
|
use Appwrite\Database\Document;
|
||
|
use Exception;
|
||
|
use Utopia\Response as UtopiaResponse;
|
||
|
|
||
|
class Response extends UtopiaResponse
|
||
|
{
|
||
|
/**
|
||
|
* HTTP content types
|
||
|
*/
|
||
|
const CONTENT_TYPE_YAML = 'application/x-yaml';
|
||
|
|
||
|
public function dynamic(Document $document)
|
||
|
{
|
||
|
# code...
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* YAML
|
||
|
*
|
||
|
* This helper is for sending YAML HTTP response.
|
||
|
* It sets relevant content type header ('application/x-yaml') and convert a PHP array ($data) to valid YAML using native yaml_parse
|
||
|
*
|
||
|
* @see https://en.wikipedia.org/wiki/YAML
|
||
|
*
|
||
|
* @param array $data
|
||
|
*/
|
||
|
public function yaml(array $data)
|
||
|
{
|
||
|
if(!extension_loaded('yaml')) {
|
||
|
throw new Exception('Missing yaml extension. Learn more at: https://www.php.net/manual/en/book.yaml.php');
|
||
|
}
|
||
|
|
||
|
$this
|
||
|
->setContentType(Response::CONTENT_TYPE_YAML)
|
||
|
->send(yaml_emit($data, YAML_UTF8_ENCODING))
|
||
|
;
|
||
|
}
|
||
|
}
|