REST_Controller::_detect_input_format PHP Метод

_detect_input_format() защищенный Метод

Get the input format e.g. json or xml
protected _detect_input_format ( ) : string | null
Результат string | null Supported input format; otherwise, NULL
    protected function _detect_input_format()
    {
        // Get the CONTENT-TYPE value from the SERVER variable
        $content_type = $this->input->server('CONTENT_TYPE');
        if (empty($content_type) === FALSE) {
            // If a semi-colon exists in the string, then explode by ; and get the value of where
            // the current array pointer resides. This will generally be the first element of the array
            $content_type = strpos($content_type, ';') !== FALSE ? current(explode(';', $content_type)) : $content_type;
            // Check all formats against the CONTENT-TYPE header
            foreach ($this->_supported_formats as $type => $mime) {
                // $type = format e.g. csv
                // $mime = mime type e.g. application/csv
                // If both the mime types match, then return the format
                if ($content_type === $mime) {
                    return $type;
                }
            }
        }
        return NULL;
    }