You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 2 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Config\BaseConfig;
  4. use CodeIgniter\Format\FormatterInterface;
  5. use CodeIgniter\Format\JSONFormatter;
  6. use CodeIgniter\Format\XMLFormatter;
  7. class Format extends BaseConfig
  8. {
  9. /**
  10. * --------------------------------------------------------------------------
  11. * Available Response Formats
  12. * --------------------------------------------------------------------------
  13. *
  14. * When you perform content negotiation with the request, these are the
  15. * available formats that your application supports. This is currently
  16. * only used with the API\ResponseTrait. A valid Formatter must exist
  17. * for the specified format.
  18. *
  19. * These formats are only checked when the data passed to the respond()
  20. * method is an array.
  21. *
  22. * @var string[]
  23. */
  24. public $supportedResponseFormats = [
  25. 'application/json',
  26. 'application/xml', // machine-readable XML
  27. 'text/xml', // human-readable XML
  28. ];
  29. /**
  30. * --------------------------------------------------------------------------
  31. * Formatters
  32. * --------------------------------------------------------------------------
  33. *
  34. * Lists the class to use to format responses with of a particular type.
  35. * For each mime type, list the class that should be used. Formatters
  36. * can be retrieved through the getFormatter() method.
  37. *
  38. * @var array<string, string>
  39. */
  40. public $formatters = [
  41. 'application/json' => JSONFormatter::class,
  42. 'application/xml' => XMLFormatter::class,
  43. 'text/xml' => XMLFormatter::class,
  44. ];
  45. /**
  46. * --------------------------------------------------------------------------
  47. * Formatters Options
  48. * --------------------------------------------------------------------------
  49. *
  50. * Additional Options to adjust default formatters behaviour.
  51. * For each mime type, list the additional options that should be used.
  52. *
  53. * @var array<string, int>
  54. */
  55. public $formatterOptions = [
  56. 'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
  57. 'application/xml' => 0,
  58. 'text/xml' => 0,
  59. ];
  60. /**
  61. * A Factory method to return the appropriate formatter for the given mime type.
  62. *
  63. * @return FormatterInterface
  64. *
  65. * @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
  66. */
  67. public function getFormatter(string $mime)
  68. {
  69. return Services::format()->getFormatter($mime);
  70. }
  71. }