Use native json_encode to convert treeView objects to JSON.

This should improve the performance.
This commit is contained in:
Jan Böhmer 2020-01-02 23:21:37 +01:00
parent fbcfc1f2a8
commit 811dca691b
4 changed files with 60 additions and 11 deletions

View file

@ -21,7 +21,7 @@
namespace App\Helpers\Trees;
class TreeViewNodeState
class TreeViewNodeState implements \JsonSerializable
{
/** @var bool|null */
protected $checked = null;
@ -73,4 +73,25 @@ class TreeViewNodeState
{
$this->selected = $selected;
}
/**
* @inheritDoc
*/
public function jsonSerialize()
{
$ret = [];
if ($this->selected !== null) {
$ret['selected'] = $this->selected;
}
if($this->disabled !== null) {
$ret['disabled'] = $this->disabled;
}
if($this->expanded !== null) {
$ret['expanded'] = $this->expanded;
}
return $ret;
}
}