1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00
appwrite/src/Appwrite/Response/Response.php

43 lines
1,012 B
PHP
Raw Normal View History

2020-05-16 23:28:26 +12:00
<?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))
;
}
}