ci4

Форк
0
/
Format.php 
77 строк · 2.6 Кб
1
<?php
2

3
namespace Config;
4

5
use CodeIgniter\Config\BaseConfig;
6
use CodeIgniter\Format\FormatterInterface;
7
use CodeIgniter\Format\JSONFormatter;
8
use CodeIgniter\Format\XMLFormatter;
9

10
class Format extends BaseConfig
11
{
12
    /**
13
     * --------------------------------------------------------------------------
14
     * Available Response Formats
15
     * --------------------------------------------------------------------------
16
     *
17
     * When you perform content negotiation with the request, these are the
18
     * available formats that your application supports. This is currently
19
     * only used with the API\ResponseTrait. A valid Formatter must exist
20
     * for the specified format.
21
     *
22
     * These formats are only checked when the data passed to the respond()
23
     * method is an array.
24
     *
25
     * @var list<string>
26
     */
27
    public array $supportedResponseFormats = [
28
        'application/json',
29
        'application/xml', // machine-readable XML
30
        'text/xml', // human-readable XML
31
    ];
32

33
    /**
34
     * --------------------------------------------------------------------------
35
     * Formatters
36
     * --------------------------------------------------------------------------
37
     *
38
     * Lists the class to use to format responses with of a particular type.
39
     * For each mime type, list the class that should be used. Formatters
40
     * can be retrieved through the getFormatter() method.
41
     *
42
     * @var array<string, string>
43
     */
44
    public array $formatters = [
45
        'application/json' => JSONFormatter::class,
46
        'application/xml'  => XMLFormatter::class,
47
        'text/xml'         => XMLFormatter::class,
48
    ];
49

50
    /**
51
     * --------------------------------------------------------------------------
52
     * Formatters Options
53
     * --------------------------------------------------------------------------
54
     *
55
     * Additional Options to adjust default formatters behaviour.
56
     * For each mime type, list the additional options that should be used.
57
     *
58
     * @var array<string, int>
59
     */
60
    public array $formatterOptions = [
61
        'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
62
        'application/xml'  => 0,
63
        'text/xml'         => 0,
64
    ];
65

66
    /**
67
     * A Factory method to return the appropriate formatter for the given mime type.
68
     *
69
     * @return FormatterInterface
70
     *
71
     * @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
72
     */
73
    public function getFormatter(string $mime)
74
    {
75
        return Services::format()->getFormatter($mime);
76
    }
77
}
78

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.