5 class View extends \Rsi\Fred\Component{
22 if($this->numericCheck) array_walk_recursive($data,
function(&$value){
23 if(\
Rsi\Str::numeric($value) && (strpos(
'.',$value) || (abs($value) < $this->maxInt))) $value += 0;
25 return json_encode($data,$this->_fred->debug ? JSON_PRETTY_PRINT : null);
29 if(!headers_sent()) header(
'Content-type: application/json; charset=utf-8');
31 if($error = json_last_error())
32 $this->_fred->log->error(
'JSON encoding error: ' . json_last_error_msg(),__FILE__,__LINE__,compact(
'data',
'error'));
36 $request = $this->_fred->request;
38 'data' => $request->data,
39 'result' => $request->result,
41 if(!$request->action) $data[
'config'] = array_merge(
42 $this->_fred->clientConfig(),
43 [
'controller' => $this->_controller->clientConfig()]
45 if($request->errors) $data[
'errors'] = $request->errors;
46 if($request->redir) $data[
'redir'] = $request->redir;
47 elseif($messages = $this->
component(
'message')->retrieve()) $data[
'messages'] = $messages;
$maxInt
Higher numbers (integers) will not be converted (from string).
publish($property, $visibility=self::READABLE)
Publish a property (or hide it again).
component($name)
Get a component (local or default).
$numericCheck
Convert numeric strings to numbers.