Controllers\xAPI\StatementIndexController::index PHP Method

index() public method

https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#723-getstatements
public index ( $options ) : Response
return Response
    public function index($options)
    {
        // Gets the acceptable languages.
        $langs = LockerRequest::header('Accept-Language', []);
        $langs = is_array($langs) ? $langs : explode(',', $langs);
        $langs = array_map(function ($lang) {
            return explode(';', $lang)[0];
        }, $langs);
        // Gets the params.
        $params = LockerRequest::all();
        if (isset($params['agent'])) {
            $decoded_agent = json_decode($params['agent']);
            if ($decoded_agent !== null) {
                $params['agent'] = $decoded_agent;
            }
        }
        // Gets an index of the statements with the given options.
        list($statements, $count, $opts) = $this->statements->index(array_merge(['langs' => $langs], $params, $options));
        // Defines the content type and body of the response.
        if ($opts['attachments'] === true) {
            $content_type = Helpers::mixedMultipartContentType();
            $body = function () use($statements, $count, $opts) {
                return $this->makeAttachmentsResult($statements, $count, $opts);
            };
        } else {
            $content_type = 'application/json;';
            $body = function () use($statements, $count, $opts) {
                return $this->makeStatementsResult($statements, $count, $opts);
            };
        }
        // Creates the response.
        return \Response::stream($body, 200, ['Content-Type' => $content_type, 'X-Experience-API-Consistent-Through' => Helpers::getCurrentDate()]);
    }