You are here

class WriteCheckSessionHandler in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php \Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler

Wraps another SessionHandlerInterface to only write the session when it has been modified.

@author Adrien Brault <adrien.brault@gmail.com>

Hierarchy

  • class \Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler implements \Symfony\Component\HttpFoundation\Session\Storage\Handler\SessionHandlerInterface

Expanded class hierarchy of WriteCheckSessionHandler

1 file declares its use of WriteCheckSessionHandler
WriteCheckSessionHandlerTest.php in vendor/symfony/http-foundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php
1 string reference to 'WriteCheckSessionHandler'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses WriteCheckSessionHandler
session_handler.write_check in core/core.services.yml
Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler

File

vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php, line 19

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler
View source
class WriteCheckSessionHandler implements \SessionHandlerInterface {

  /**
   * @var \SessionHandlerInterface
   */
  private $wrappedSessionHandler;

  /**
   * @var array sessionId => session
   */
  private $readSessions;
  public function __construct(\SessionHandlerInterface $wrappedSessionHandler) {
    $this->wrappedSessionHandler = $wrappedSessionHandler;
  }

  /**
   * {@inheritdoc}
   */
  public function close() {
    return $this->wrappedSessionHandler
      ->close();
  }

  /**
   * {@inheritdoc}
   */
  public function destroy($sessionId) {
    return $this->wrappedSessionHandler
      ->destroy($sessionId);
  }

  /**
   * {@inheritdoc}
   */
  public function gc($maxlifetime) {
    return $this->wrappedSessionHandler
      ->gc($maxlifetime);
  }

  /**
   * {@inheritdoc}
   */
  public function open($savePath, $sessionName) {
    return $this->wrappedSessionHandler
      ->open($savePath, $sessionName);
  }

  /**
   * {@inheritdoc}
   */
  public function read($sessionId) {
    $session = $this->wrappedSessionHandler
      ->read($sessionId);
    $this->readSessions[$sessionId] = $session;
    return $session;
  }

  /**
   * {@inheritdoc}
   */
  public function write($sessionId, $data) {
    if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) {
      return true;
    }
    return $this->wrappedSessionHandler
      ->write($sessionId, $data);
  }

}

Members