-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerialize.php
More file actions
51 lines (41 loc) · 1.06 KB
/
Serialize.php
File metadata and controls
51 lines (41 loc) · 1.06 KB
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
51
<?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;
// serialize
// class for a column which should serialize its value
class Serialize extends Core\ColAlias
{
// config
protected static array $config = [
'search'=>false,
'check'=>['kind'=>'text'],
'onComplex'=>true
];
// onGet
// get la value à déserializer
protected function onGet($return,?Orm\Cell $cell,array $option)
{
if(is_string($return))
$return = Base\Crypt::unserialize($return);
return $return;
}
// onSet
// set la value, à serializer
protected function onSet($return,?Orm\Cell $cell,array $row,array $option)
{
if(is_array($return) || is_object($return))
$return = Base\Crypt::serialize($return);
return $return;
}
}
// init
Serialize::__init();
?>