Closed lathspell closed 6 years ago
Meanwhile this seems to work:
Scope::set("TextPlainFormat", new TextPlainFormat());
$restler = new Restler();
$restler->setOverridingFormats('TextPlainFormat');
...
with:
<?php
namespace netcologne\ocms\apex360;
use Luracast\Restler\Format\Format;
class TextPlainFormat extends Format
{
const MIME = 'text/plain';
public function encode($data, $humanReadable = false)
{
return $data;
}
public function decode($data)
{
return $data;
}
}
and
...
* @url GET /ping
* @format TextPlainFormat
* @return string "pong"
*/
public function ping()
...
If you are planning to use text/plain
as an input format, you should add isReadable
too
class TextPlainFormat extends Format
{
const MIME = 'text/plain';
public function encode($data, $humanReadable = false)
{
return $data;
}
public function decode($data)
{
return $data;
}
/**
* @return bool false as text/plain format is write only
*/
public function isReadable()
{
return false;
}
}
Why is there no text/plain format i.e. Format/TextPlainFormat.php class?