class TestSessionHandlerProxy

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php \Drupal\session_test\Session\TestSessionHandlerProxy
  2. 10 core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php \Drupal\session_test\Session\TestSessionHandlerProxy
  3. 11.x core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php \Drupal\session_test\Session\TestSessionHandlerProxy

Provides a test session handler proxy.

Hierarchy

  • class \Drupal\session_test\Session\TestSessionHandlerProxy implements \Drupal\session_test\Session\SessionHandlerInterface

Expanded class hierarchy of TestSessionHandlerProxy

1 string reference to 'TestSessionHandlerProxy'
session_test.services.yml in core/modules/system/tests/modules/session_test/session_test.services.yml
core/modules/system/tests/modules/session_test/session_test.services.yml
2 services use TestSessionHandlerProxy
session_test.session_handler.test_proxy in core/modules/system/tests/modules/session_test/session_test.services.yml
Drupal\session_test\Session\TestSessionHandlerProxy
session_test.session_handler.test_proxy2 in core/modules/system/tests/modules/session_test/session_test.services.yml
Drupal\session_test\Session\TestSessionHandlerProxy

File

core/modules/system/tests/modules/session_test/src/Session/TestSessionHandlerProxy.php, line 8

Namespace

Drupal\session_test\Session
View source
class TestSessionHandlerProxy implements \SessionHandlerInterface {
    
    /**
     * The decorated session handler.
     *
     * @var \SessionHandlerInterface
     */
    protected $sessionHandler;
    
    /**
     * An optional argument.
     *
     * @var mixed
     */
    protected $optionalArgument;
    
    /**
     * Constructs a new TestSessionHandlerProxy object.
     *
     * @param \SessionHandlerInterface $session_handler
     *   The decorated session handler.
     * @param mixed $optional_argument
     *   (optional) An optional argument.
     */
    public function __construct(\SessionHandlerInterface $session_handler, $optional_argument = NULL) {
        $this->sessionHandler = $session_handler;
        $this->optionalArgument = $optional_argument;
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }
    
    /**
     * {@inheritdoc}
     */
    public function destroy($session_id) {
        return $this->sessionHandler
            ->destroy($session_id);
    }
    
    /**
     * {@inheritdoc}
     */
    public function gc($max_lifetime) {
        return $this->sessionHandler
            ->gc($max_lifetime);
    }

}

Members

Title Sort descending Modifiers Object type Summary
TestSessionHandlerProxy::$optionalArgument protected property An optional argument.
TestSessionHandlerProxy::$sessionHandler protected property The decorated session handler.
TestSessionHandlerProxy::close public function
TestSessionHandlerProxy::destroy public function
TestSessionHandlerProxy::gc public function
TestSessionHandlerProxy::open public function
TestSessionHandlerProxy::read public function
TestSessionHandlerProxy::write public function
TestSessionHandlerProxy::__construct public function Constructs a new TestSessionHandlerProxy object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.