paulgoughbooks_old
This repository has no backups
This repository's network speed is throttled to 100KB/sec
Upgrade your account to fix these warnings, or use backups.vc for automated backups
@ 2
paulgoughbooks_old / trunk / app / Config / Format.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
<?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, ]; /* |-------------------------------------------------------------------------- | Formatters Options |-------------------------------------------------------------------------- | | Additional Options to adjust default formatters behaviour. | For each mime type, list the additional options that should be used. | */ public $formatterOptions = [ 'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, 'application/xml' => 0, 'text/xml' => 0, ]; //-------------------------------------------------------------------- /** * 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(); } //-------------------------------------------------------------------- } |
Commits for paulgoughbooks_old/trunk/app/Config/Format.php
Revision | Author | Commited | Message |
---|---|---|---|
2 | tporter | Tue 03 Nov, 2020 08:50:21 +0000 | Migration of Paul Goughs Books site to Codeignitor 4 |