Пример #1
0
 public function testGetOffsetIsAtLeastZero()
 {
     $criteria = new Criteria(['page' => ['offset' => -5]]);
     $this->assertEquals(0, $criteria->getOffset());
 }
Пример #2
0
 /**
  * Extract parameters from the request input and assign them to the
  * request, restricted by the action's specifications.
  *
  * @param Request $request
  * @return JsonApiRequest
  */
 protected function buildJsonApiRequest(Request $request)
 {
     $request = new JsonApiRequest($request->input, $request->actor, $request->http);
     $criteria = new Criteria($request->input);
     event(new BuildApiAction($this));
     $request->include = $this->sanitizeInclude($criteria->getInclude());
     $request->sort = $this->sanitizeSort($criteria->getSort());
     $request->offset = $criteria->getOffset();
     $request->limit = $this->sanitizeLimit($criteria->getLimit());
     $request->link = $this->link;
     return $request;
 }
Пример #3
0
 /**
  * Extract parameters from the request input and assign them to the
  * request, restricted by the action's specifications.
  *
  * @param \Flarum\Api\Request $request
  * @return void
  */
 protected static function buildJsonApiRequest(Request $request)
 {
     $request = new JsonApiRequest($request->input, $request->actor, $request->http);
     $criteria = new Criteria($request->input);
     $request->include = static::sanitizeInclude($criteria->getInclude());
     $request->sort = static::sanitizeSort($criteria->getSort());
     $request->offset = $criteria->getOffset();
     $request->limit = static::sanitizeLimit($criteria->getLimit());
     $request->link = static::$link;
     return $request;
 }