/** * Determines the correct serializer from an incoming request. * * @param \SS_HTTPRequest $request the request object * @return IRestSerializer a new instance of a serializer which fits the request best * @throws RestUserException */ public static function create_from_request($request) { if ($type = $request->getVar('accept')) { try { if (array_key_exists($type, self::$lookup)) { return self::create(self::$lookup[$type]); } } catch (\Exception $e) { } } $types = $request->getAcceptMimetypes(); foreach ($types as $type) { try { return self::create($type); } catch (RestUserException $e) { } } return self::create(); }
/** * Lists files either as json or as a list of anchors depending on Accept header containing application/json or other. * * SideEffects: * outputs the response to output buffer, so can't echo ReplicantProgressLogEntry here. * * @param SS_HTTPRequest $request * @return the number of files listed */ protected function listFiles(SS_HTTPRequest $request) { return ReplicantActionListFiles::create()->checkPerm()->update(array())->execute($request->getAcceptMimetypes()); }