-
Notifications
You must be signed in to change notification settings - Fork 0
/
Json.php
50 lines (40 loc) · 1019 Bytes
/
Json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/core/blob/master/LICENSE
*/
namespace Quid\Core\Col;
use Quid\Base;
use Quid\Core;
use Quid\Orm;
// json
// class for a column which manages json values
class Json extends Core\ColAlias
{
// config
protected static array $config = [
'search'=>false,
'check'=>['kind'=>'text']
];
// onGet
// sur le onGet du json
protected function onGet($return,?Orm\Cell $cell,array $option)
{
if(Base\Json::is($return))
$return = Base\Json::decode($return);
return $return;
}
// onSet
// sur le onSet du json
protected function onSet($return,?Orm\Cell $cell,array $row,array $option)
{
if(is_array($return) || is_object($return))
$return = Base\Json::encode($return);
return $return;
}
}
// init
Json::__init();
?>