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);
|
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');
|
$response->addHeader('Content-Type', 'application/json');
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -95,12 +95,12 @@ class VersionProvider
|
|||||||
$cache = Injector::inst()->get(CacheInterface::class . '.VersionProvider_composerlock');
|
$cache = Injector::inst()->get(CacheInterface::class . '.VersionProvider_composerlock');
|
||||||
$cacheKey = md5($jsonData);
|
$cacheKey = md5($jsonData);
|
||||||
if ($versions = $cache->get($cacheKey)) {
|
if ($versions = $cache->get($cacheKey)) {
|
||||||
$lockData = Convert::json2array($versions);
|
$lockData = json_decode($versions, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($lockData) && $jsonData) {
|
if (empty($lockData) && $jsonData) {
|
||||||
$lockData = Convert::json2array($jsonData);
|
$lockData = json_decode($jsonData, true);
|
||||||
|
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
$cache->set($cacheKey, $jsonData);
|
$cache->set($cacheKey, $jsonData);
|
||||||
|
@ -376,7 +376,7 @@ class FormRequestHandler extends RequestHandler
|
|||||||
$acceptType = $this->getRequest()->getHeader('Accept');
|
$acceptType = $this->getRequest()->getHeader('Accept');
|
||||||
if (strpos($acceptType, 'application/json') !== false) {
|
if (strpos($acceptType, 'application/json') !== false) {
|
||||||
// Send validation errors back as JSON with a flag at the start
|
// 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');
|
$response->addHeader('Content-Type', 'application/json');
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Config::unnest();
|
Config::unnest();
|
||||||
$response = new HTTPResponse(Convert::array2json($json));
|
$response = new HTTPResponse(json_encode($json));
|
||||||
$response->addHeader('Content-Type', 'application/json');
|
$response->addHeader('Content-Type', 'application/json');
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi
|
|||||||
'clearAction' => GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->getAttribute('name')
|
'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()
|
$data = FormSchema::singleton()
|
||||||
->getMultipartSchema($parts, $schemaID, $form);
|
->getMultipartSchema($parts, $schemaID, $form);
|
||||||
|
|
||||||
$response = new HTTPResponse(Convert::raw2json($data));
|
$response = new HTTPResponse(json_encode($data));
|
||||||
$response->addHeader('Content-Type', 'application/json');
|
$response->addHeader('Content-Type', 'application/json');
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class GridField_ActionMenu implements GridField_ColumnProvider, GridField_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
$templateData = ArrayData::create([
|
$templateData = ArrayData::create([
|
||||||
'Schema' => Convert::raw2json($schema),
|
'Schema' => json_encode($schema),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$template = SSViewer::get_templates_by_class($this, '', static::class);
|
$template = SSViewer::get_templates_by_class($this, '', static::class);
|
||||||
|
@ -371,7 +371,7 @@ class TinyMCEConfig extends HTMLEditorConfig
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'data-editor' => 'tinyMCE', // Register ss.editorWrappers.tinyMCE
|
'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()
|
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)
|
array((string)$btns[0]['name'] => 1)
|
||||||
);
|
);
|
||||||
$this->assertFalse($response->isError());
|
$this->assertFalse($response->isError());
|
||||||
$result = Convert::json2array($response->getBody());
|
$result = json_decode($response->getBody(), true);
|
||||||
$this->assertEquals(1, count($result));
|
$this->assertEquals(1, count($result));
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(array(
|
array(array(
|
||||||
@ -81,7 +81,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
|||||||
array((string)$btns[0]['name'] => 1)
|
array((string)$btns[0]['name'] => 1)
|
||||||
);
|
);
|
||||||
$this->assertFalse($response->isError());
|
$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");
|
$this->assertEquals(1, count($result), "The relational filter did not work");
|
||||||
|
|
||||||
$response = $this->post(
|
$response = $this->post(
|
||||||
@ -90,7 +90,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
|||||||
array((string)$btns[0]['name'] => 1)
|
array((string)$btns[0]['name'] => 1)
|
||||||
);
|
);
|
||||||
$this->assertFalse($response->isError());
|
$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');
|
$this->assertEmpty($result, 'The output is either an empty array or boolean FALSE');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class HTMLEditorConfigTest extends SapphireTest
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$attributes = $c->getAttributes();
|
$attributes = $c->getAttributes();
|
||||||
$config = Convert::json2array($attributes['data-config']);
|
$config = json_decode($attributes['data-config'], true);
|
||||||
$plugins = $config['external_plugins'];
|
$plugins = $config['external_plugins'];
|
||||||
$this->assertNotEmpty($plugins);
|
$this->assertNotEmpty($plugins);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user