View source
<?php
namespace Drupal\session_test\Session;
class TestSessionHandlerProxy implements \SessionHandlerInterface {
protected $sessionHandler;
protected $optionalArgument;
public function __construct(\SessionHandlerInterface $session_handler, $optional_argument = NULL) {
$this->sessionHandler = $session_handler;
$this->optionalArgument = $optional_argument;
}
public function open($save_path, $name) {
$trace = \Drupal::service('session_test.session_handler_proxy_trace');
$trace[] = [
'BEGIN',
$this->optionalArgument,
__FUNCTION__,
];
$result = $this->sessionHandler
->open($save_path, $name);
$trace[] = [
'END',
$this->optionalArgument,
__FUNCTION__,
];
return $result;
}
public function close() {
$trace = \Drupal::service('session_test.session_handler_proxy_trace');
$trace[] = [
'BEGIN',
$this->optionalArgument,
__FUNCTION__,
];
$result = $this->sessionHandler
->close();
$trace[] = [
'END',
$this->optionalArgument,
__FUNCTION__,
];
return $result;
}
public function read($session_id) {
$trace = \Drupal::service('session_test.session_handler_proxy_trace');
$trace[] = [
'BEGIN',
$this->optionalArgument,
__FUNCTION__,
$session_id,
];
$result = $this->sessionHandler
->read($session_id);
$trace[] = [
'END',
$this->optionalArgument,
__FUNCTION__,
$session_id,
];
return $result;
}
public function write($session_id, $session_data) {
$trace = \Drupal::service('session_test.session_handler_proxy_trace');
$trace[] = [
'BEGIN',
$this->optionalArgument,
__FUNCTION__,
$session_id,
];
$result = $this->sessionHandler
->write($session_id, $session_data);
$trace[] = [
'END',
$this->optionalArgument,
__FUNCTION__,
$session_id,
];
return $result;
}
public function destroy($session_id) {
return $this->sessionHandler
->destroy($session_id);
}
public function gc($max_lifetime) {
return $this->sessionHandler
->gc($max_lifetime);
}
}