3 namespace Drupal\session_test\Session;
6 * Provides a test session handler proxy.
8 class TestSessionHandlerProxy implements \SessionHandlerInterface {
11 * The decorated session handler.
13 * @var \SessionHandlerInterface
15 protected $sessionHandler;
18 * An optional argument.
22 protected $optionalArgument;
25 * Constructs a new TestSessionHandlerProxy object.
27 * @param \SessionHandlerInterface $session_handler
28 * The decorated session handler.
29 * @param mixed $optional_argument
30 * (optional) An optional argument.
32 public function __construct(\SessionHandlerInterface $session_handler, $optional_argument = NULL) {
33 $this->sessionHandler = $session_handler;
34 $this->optionalArgument = $optional_argument;
40 public function open($save_path, $name) {
41 $trace = \Drupal::service('session_test.session_handler_proxy_trace');
42 $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__];
43 $result = $this->sessionHandler->open($save_path, $name);
44 $trace[] = ['END', $this->optionalArgument, __FUNCTION__];
51 public function close() {
52 $trace = \Drupal::service('session_test.session_handler_proxy_trace');
53 $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__];
54 $result = $this->sessionHandler->close();
55 $trace[] = ['END', $this->optionalArgument, __FUNCTION__];
62 public function read($session_id) {
63 $trace = \Drupal::service('session_test.session_handler_proxy_trace');
64 $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__, $session_id];
65 $result = $this->sessionHandler->read($session_id);
66 $trace[] = ['END', $this->optionalArgument, __FUNCTION__, $session_id];
73 public function write($session_id, $session_data) {
74 $trace = \Drupal::service('session_test.session_handler_proxy_trace');
75 $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__, $session_id];
76 $result = $this->sessionHandler->write($session_id, $session_data);
77 $trace[] = ['END', $this->optionalArgument, __FUNCTION__, $session_id];
84 public function destroy($session_id) {
85 return $this->sessionHandler->destroy($session_id);
91 public function gc($max_lifetime) {
92 return $this->sessionHandler->gc($max_lifetime);