Skip to content

Commit 01ce1ba

Browse files
committed
SimpleIdentity: uses __serialize & __unserialize
1 parent 9f326d4 commit 01ce1ba

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
@@ -113,4 +113,22 @@ public function __isset(string $key): bool
113113
{
114114
return isset($this->data[$key]) || in_array($key, ['id', 'roles', 'data'], strict: true);
115115
}
116+
117+
118+
public function __serialize(): array
119+
{
120+
return [
121+
'id' => $this->id,
122+
'roles' => $this->roles,
123+
'data' => $this->data,
124+
];
125+
}
126+
127+
128+
public function __unserialize(array $data): void
129+
{
130+
$this->id = $data['id'] ?? $data["\00Nette\\Security\\Identity\00id"] ?? 0;
131+
$this->roles = $data['roles'] ?? $data["\00Nette\\Security\\Identity\00roles"] ?? [];
132+
$this->data = $data['data'] ?? $data["\00Nette\\Security\\Identity\00data"] ?? [];
133+
}
116134
}

0 commit comments

Comments
 (0)