-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSession.php
More file actions
49 lines (40 loc) · 1.19 KB
/
Session.php
File metadata and controls
49 lines (40 loc) · 1.19 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
<?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\Core;
// session
// class for a column which should store current session id
class Session extends EnumAlias
{
// config
protected static array $config = [
'visible'=>['validate'=>'notEmpty'],
'required'=>false,
'complex'=>'div',
'inRelation'=>false // custom, n'a pas besoin d'être dans la relation
];
// onCommit
// retourne le id de la session sur insertion ou sur update
// note: retourne null si le storage de session n'est pas une row de base de données
final protected function onCommit($value,?Core\Cell $cell,array $row,array $option):?Core\Row
{
$return = null;
$boot = static::bootReady();
if(!empty($boot))
{
$session = $boot->session();
$storage = $session->storage();
if($storage instanceof Core\Row)
$return = $storage;
}
return $return;
}
}
// init
Session::__init();
?>