Skip to content
Snippets Groups Projects

remove deprecations

Merged Patrick Kenny requested to merge issue/jsonapi_include-3483573:remove_deprecations into 2.0.x
2 files
+ 12
37
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 8
28
@@ -46,13 +46,7 @@ class JsonapiParse implements JsonapiParseInterface {
* {@inheritdoc}
*/
#[\Override]
public function parse(Response|string $response): Response|string {
// @todo Remove in the release 2.0 with removed the deprecated strings input.
if (!$response instanceof Response) {
@trigger_error('Parsing strings is deprecated in jsonapi_include:8.x-1.7 and is removed from jsonapi_include:8.x-2.0. Pass the full Response object instead. See https://www.drupal.org/project/jsonapi_include/issues/3374410', E_USER_DEPRECATED);
$content = $this->parseJsonContent($response);
return Json::encode($content);
}
public function parse(Response $response): Response {
$this->parseJsonContent($response);
return $response;
}
@@ -249,20 +243,12 @@ class JsonapiParse implements JsonapiParseInterface {
* Returns an array with the response content, if the input is string or
* array, or void if input is a Response.
*/
protected function parseJsonContent(Response|string|array $response): Response|array {
if ($response instanceof Response) {
$content = $response->getContent();
if (is_string($content)) {
$content = Json::decode($content);
}
}
// @todo Remove in the release 2.0 with removed the deprecated string input.
elseif (is_array($response)) {
$content = $response;
}
elseif (is_string($response)) {
$content = Json::decode($response);
protected function parseJsonContent(Response $response): Response|array {
$content = $response->getContent();
if (is_string($content)) {
$content = Json::decode($content);
}
if (NestedArray::getValue($content, ['jsonapi', 'parsed'])) {
return $response;
}
@@ -286,14 +272,8 @@ class JsonapiParse implements JsonapiParseInterface {
}
$content['jsonapi']['parsed'] = TRUE;
$content['data'] = $data;
if ($response instanceof Response) {
$response->setContent(Json::encode($content));
return $response;
}
// @todo Remove in the release 2.0 with removed the deprecated strings input.
else {
return $content;
}
$response->setContent(Json::encode($content));
return $response;
}
}
Loading