Skip to content

Commit a598a80

Browse files
committed
SimpleIdentity: uses __serialize & __unserialize
1 parent 0921b41 commit a598a80

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Security/SimpleIdentity.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,22 @@ public function __isset(string $key): bool
114114
{
115115
return isset($this->data[$key]) || in_array($key, ['id', 'roles', 'data'], strict: true);
116116
}
117+
118+
119+
public function __serialize(): array
120+
{
121+
return [
122+
'id' => $this->id,
123+
'roles' => $this->roles,
124+
'data' => $this->data,
125+
];
126+
}
127+
128+
129+
public function __unserialize(array $data): void
130+
{
131+
$this->id = $data['id'] ?? $data["\00Nette\\Security\\Identity\00id"] ?? 0;
132+
$this->roles = $data['roles'] ?? $data["\00Nette\\Security\\Identity\00roles"] ?? [];
133+
$this->data = $data['data'] ?? $data["\00Nette\\Security\\Identity\00data"] ?? [];
134+
}
117135
}

0 commit comments

Comments
 (0)