Skip to content

Commit eb0d795

Browse files
committed
SimpleIdentity: uses __serialize & __unserialize
1 parent 3f3440e commit eb0d795

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/Security/SimpleIdentity.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,22 @@ public function __isset(string $key): bool
122122
{
123123
return isset($this->data[$key]) || in_array($key, ['id', 'roles', 'data'], strict: true);
124124
}
125+
126+
127+
public function __serialize(): array
128+
{
129+
return [
130+
'id' => $this->id,
131+
'roles' => $this->roles,
132+
'data' => $this->data,
133+
];
134+
}
135+
136+
137+
public function __unserialize(array $data): void
138+
{
139+
$this->id = $data['id'] ?? $data["\00Nette\\Security\\Identity\00id"] ?? 0;
140+
$this->roles = $data['roles'] ?? $data["\00Nette\\Security\\Identity\00roles"] ?? [];
141+
$this->data = $data['data'] ?? $data["\00Nette\\Security\\Identity\00data"] ?? [];
142+
}
125143
}

0 commit comments

Comments
 (0)