| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; |
| 13 |
|
| 14 |
use Symfony\Component\Cache\Marshaller\MarshallerInterface; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
class MarshallingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface |
| 20 |
{ |
| 21 |
public function __construct( |
| 22 |
private AbstractSessionHandler $handler, |
| 23 |
private MarshallerInterface $marshaller, |
| 24 |
) { |
| 25 |
} |
| 26 |
|
| 27 |
public function open(string $savePath, string $name): bool |
| 28 |
{ |
| 29 |
return $this->handler->open($savePath, $name); |
| 30 |
} |
| 31 |
|
| 32 |
public function close(): bool |
| 33 |
{ |
| 34 |
return $this->handler->close(); |
| 35 |
} |
| 36 |
|
| 37 |
public function destroy(#[\SensitiveParameter] string $sessionId): bool |
| 38 |
{ |
| 39 |
return $this->handler->destroy($sessionId); |
| 40 |
} |
| 41 |
|
| 42 |
public function gc(int $maxlifetime): int|false |
| 43 |
{ |
| 44 |
return $this->handler->gc($maxlifetime); |
| 45 |
} |
| 46 |
|
| 47 |
public function read(#[\SensitiveParameter] string $sessionId): string |
| 48 |
{ |
| 49 |
return $this->marshaller->unmarshall($this->handler->read($sessionId)); |
| 50 |
} |
| 51 |
|
| 52 |
public function write(#[\SensitiveParameter] string $sessionId, string $data): bool |
| 53 |
{ |
| 54 |
$failed = []; |
| 55 |
$marshalledData = $this->marshaller->marshall(['data' => $data], $failed); |
| 56 |
|
| 57 |
if (isset($failed['data'])) { |
| 58 |
return false; |
| 59 |
} |
| 60 |
|
| 61 |
return $this->handler->write($sessionId, $marshalledData['data']); |
| 62 |
} |
| 63 |
|
| 64 |
public function validateId(#[\SensitiveParameter] string $sessionId): bool |
| 65 |
{ |
| 66 |
return $this->handler->validateId($sessionId); |
| 67 |
} |
| 68 |
|
| 69 |
public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool |
| 70 |
{ |
| 71 |
return $this->handler->updateTimestamp($sessionId, $data); |
| 72 |
} |
| 73 |
} |