mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00

- add node service in docker-compose.yml - update .devcontainer Dockerfile by adding node, npm and vim - init package.json for npm with tailwindcss, postcss, commitlint and commitizen as dev dependencies - update default layout main header and footer - replace CI's welcome_message.php with home.php listing all podcasts - add AUTHORS.md file - add docs folder in which to place castopod's technical documentation
72 lines
2.0 KiB
PHP
72 lines
2.0 KiB
PHP
<?php namespace Config;
|
|
|
|
use CodeIgniter\Config\BaseConfig;
|
|
|
|
class Format extends BaseConfig
|
|
{
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Available Response Formats
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| When you perform content negotiation with the request, these are the
|
|
| available formats that your application supports. This is currently
|
|
| only used with the API\ResponseTrait. A valid Formatter must exist
|
|
| for the specified format.
|
|
|
|
|
| These formats are only checked when the data passed to the respond()
|
|
| method is an array.
|
|
|
|
|
*/
|
|
public $supportedResponseFormats = [
|
|
'application/json',
|
|
'application/xml', // machine-readable XML
|
|
'text/xml', // human-readable XML
|
|
];
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Formatters
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Lists the class to use to format responses with of a particular type.
|
|
| For each mime type, list the class that should be used. Formatters
|
|
| can be retrieved through the getFormatter() method.
|
|
|
|
|
*/
|
|
public $formatters = [
|
|
'application/json' => \CodeIgniter\Format\JSONFormatter::class,
|
|
'application/xml' => \CodeIgniter\Format\XMLFormatter::class,
|
|
'text/xml' => \CodeIgniter\Format\XMLFormatter::class,
|
|
];
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
/**
|
|
* A Factory method to return the appropriate formatter for the given mime type.
|
|
*
|
|
* @param string $mime
|
|
*
|
|
* @return \CodeIgniter\Format\FormatterInterface
|
|
*/
|
|
public function getFormatter(string $mime)
|
|
{
|
|
if (! array_key_exists($mime, $this->formatters))
|
|
{
|
|
throw new \InvalidArgumentException('No Formatter defined for mime type: ' . $mime);
|
|
}
|
|
|
|
$class = $this->formatters[$mime];
|
|
|
|
if (! class_exists($class))
|
|
{
|
|
throw new \BadMethodCallException($class . ' is not a valid Formatter.');
|
|
}
|
|
|
|
return new $class();
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
}
|