mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Replace usage of Convert JSON methods with json_encode
This commit is contained in:
parent
9724d1dd73
commit
b02a6fa02d
@ -102,7 +102,7 @@ class PjaxResponseNegotiator
|
||||
throw new HTTPResponse_Exception("X-Pjax = '$fragment' not supported for this URL.", 400);
|
||||
}
|
||||
}
|
||||
$response->setBody(Convert::raw2json($responseParts));
|
||||
$response->setBody(json_encode($responseParts));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
|
||||
return $response;
|
||||
|
@ -95,12 +95,12 @@ class VersionProvider
|
||||
$cache = Injector::inst()->get(CacheInterface::class . '.VersionProvider_composerlock');
|
||||
$cacheKey = md5($jsonData);
|
||||
if ($versions = $cache->get($cacheKey)) {
|
||||
$lockData = Convert::json2array($versions);
|
||||
$lockData = json_decode($versions, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($lockData) && $jsonData) {
|
||||
$lockData = Convert::json2array($jsonData);
|
||||
$lockData = json_decode($jsonData, true);
|
||||
|
||||
if ($cache) {
|
||||
$cache->set($cacheKey, $jsonData);
|
||||
|
@ -376,7 +376,7 @@ class FormRequestHandler extends RequestHandler
|
||||
$acceptType = $this->getRequest()->getHeader('Accept');
|
||||
if (strpos($acceptType, 'application/json') !== false) {
|
||||
// Send validation errors back as JSON with a flag at the start
|
||||
$response = new HTTPResponse(Convert::array2json($result->getMessages()));
|
||||
$response = new HTTPResponse(json_encode($result->getMessages()));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
);
|
||||
}
|
||||
Config::unnest();
|
||||
$response = new HTTPResponse(Convert::array2json($json));
|
||||
$response = new HTTPResponse(json_encode($json));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi
|
||||
'clearAction' => GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->getAttribute('name')
|
||||
];
|
||||
|
||||
return Convert::raw2json($schema);
|
||||
return json_encode($schema);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -377,7 +377,7 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi
|
||||
$data = FormSchema::singleton()
|
||||
->getMultipartSchema($parts, $schemaID, $form);
|
||||
|
||||
$response = new HTTPResponse(Convert::raw2json($data));
|
||||
$response = new HTTPResponse(json_encode($data));
|
||||
$response->addHeader('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class GridField_ActionMenu implements GridField_ColumnProvider, GridField_Action
|
||||
}
|
||||
|
||||
$templateData = ArrayData::create([
|
||||
'Schema' => Convert::raw2json($schema),
|
||||
'Schema' => json_encode($schema),
|
||||
]);
|
||||
|
||||
$template = SSViewer::get_templates_by_class($this, '', static::class);
|
||||
|
@ -371,7 +371,7 @@ class TinyMCEConfig extends HTMLEditorConfig
|
||||
{
|
||||
return [
|
||||
'data-editor' => 'tinyMCE', // Register ss.editorWrappers.tinyMCE
|
||||
'data-config' => Convert::array2json($this->getConfig()),
|
||||
'data-config' => json_encode($this->getConfig()),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ abstract class DBField extends ViewableData implements DBIndexable
|
||||
*/
|
||||
public function JSON()
|
||||
{
|
||||
return Convert::raw2json($this->RAW());
|
||||
return json_encode($this->RAW());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,7 +64,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
||||
array((string)$btns[0]['name'] => 1)
|
||||
);
|
||||
$this->assertFalse($response->isError());
|
||||
$result = Convert::json2array($response->getBody());
|
||||
$result = json_decode($response->getBody(), true);
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertEquals(
|
||||
array(array(
|
||||
@ -81,7 +81,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
||||
array((string)$btns[0]['name'] => 1)
|
||||
);
|
||||
$this->assertFalse($response->isError());
|
||||
$result = Convert::json2array($response->getBody());
|
||||
$result = json_decode($response->getBody(), true);
|
||||
$this->assertEquals(1, count($result), "The relational filter did not work");
|
||||
|
||||
$response = $this->post(
|
||||
@ -90,7 +90,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
||||
array((string)$btns[0]['name'] => 1)
|
||||
);
|
||||
$this->assertFalse($response->isError());
|
||||
$result = Convert::json2array($response->getBody());
|
||||
$result = json_decode($response->getBody(), true);
|
||||
$this->assertEmpty($result, 'The output is either an empty array or boolean FALSE');
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class HTMLEditorConfigTest extends SapphireTest
|
||||
)
|
||||
);
|
||||
$attributes = $c->getAttributes();
|
||||
$config = Convert::json2array($attributes['data-config']);
|
||||
$config = json_decode($attributes['data-config'], true);
|
||||
$plugins = $config['external_plugins'];
|
||||
$this->assertNotEmpty($plugins);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user