/** * @param ApiInterface $api * @return object */ protected function locateRecord(ApiInterface $api) { $interpreter = $api->getRequestInterpreter(); if (!($id = $interpreter->getResourceId())) { return null; } $store = $api->getStore(); $identifier = ResourceIdentifier::create($interpreter->getResourceType(), $id); $record = $store->find($identifier); if (!$record) { throw new JsonApiException([], 404); } return $record; }
/** * @inheritdoc */ public function handle(ApiInterface $api, RequestInterface $request) { $interpreter = $api->getRequestInterpreter(); $resourceType = $request->getResourceType(); /** Check the relationship is acceptable */ if ($request->getRelationshipName()) { $this->checkRelationshipName($request); } /** Check request parameters are acceptable */ $this->checkQueryParameters($api, $request, $this->filterValidator($resourceType)); /** Authorize the request */ if ($this->authorizer) { $this->authorize($interpreter, $this->authorizer, $request); } /** Check the document content is acceptable */ if ($this->validators) { $this->checkDocumentIsAcceptable($this->validators, $interpreter, $request); } }