Locker\Helpers\Helpers::mixedMultipartContentType PHP Method

mixedMultipartContentType() public static method

public static mixedMultipartContentType ( $boundary = null )
    public static function mixedMultipartContentType($boundary = null)
    {
        $boundary = $boundary ?: static::MULTIPART_BOUNDARY;
        return 'multipart/mixed; boundary="' . $boundary . '"';
    }

Usage Example

 /**
  * Gets an array of statements.
  * https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#723-getstatements
  * @param [String => mixed] $options
  * @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()]);
 }
All Usage Examples Of Locker\Helpers\Helpers::mixedMultipartContentType