Skip to content

Commit 1767c8e

Browse files
committed
SimpleIdentity: uses __serialize & __unserialize
1 parent 28acac6 commit 1767c8e

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
@@ -120,4 +120,22 @@ public function __isset(string $key): bool
120120
{
121121
return isset($this->data[$key]) || $this->parentIsSet($key);
122122
}
123+
124+
125+
public function __serialize(): array
126+
{
127+
return [
128+
'id' => $this->id,
129+
'roles' => $this->roles,
130+
'data' => $this->data,
131+
];
132+
}
133+
134+
135+
public function __unserialize(array $data): void
136+
{
137+
$this->id = $data['id'] ?? $data["\00Nette\\Security\\Identity\00id"] ?? 0;
138+
$this->roles = $data['roles'] ?? $data["\00Nette\\Security\\Identity\00roles"] ?? [];
139+
$this->data = $data['data'] ?? $data["\00Nette\\Security\\Identity\00data"] ?? [];
140+
}
123141
}

0 commit comments

Comments
 (0)