You are here

class SessionLimitDisconnectEvent in Session Limit 2.x

Same name and namespace in other branches
  1. 8 src/Event/SessionLimitDisconnectEvent.php \Drupal\session_limit\Event\SessionLimitDisconnectEvent

Hierarchy

Expanded class hierarchy of SessionLimitDisconnectEvent

1 file declares its use of SessionLimitDisconnectEvent
SessionLimit.php in src/Services/SessionLimit.php

File

src/Event/SessionLimitDisconnectEvent.php, line 8

Namespace

Drupal\session_limit\Event
View source
class SessionLimitDisconnectEvent extends Event {

  /**
   * @var int
   */
  protected $sessionId;

  /**
   * @var SessionLimitCollisionEvent
   */
  protected $collisionEvent;

  /**
   * @var bool
   */
  protected $preventDisconnect = FALSE;

  /**
   * @var string
   */
  protected $message;

  /**
   * SessionLimitCollisionEvent constructor.
   *
   * @param int $sessionId
   * @param SessionLimitCollisionEvent $collisionEvent
   * @param string $message
   */
  public function __construct($sessionId, SessionLimitCollisionEvent $collisionEvent, $message) {
    $this->sessionId = $sessionId;
    $this->collisionEvent = $collisionEvent;
    $this->message = $message;
  }

  /**
   * @return int
   */
  public function getSessionId() {
    return $this->sessionId;
  }

  /**
   * @return SessionLimitCollisionEvent
   */
  public function getCollisionEvent() {
    return $this->collisionEvent;
  }

  /**
   * Call to prevent the session being disconnected.
   *
   * @param bool $state
   *   Set to TRUE to prevent the disconnection (default) any other
   *   value is ignored. Just one listener to the event calling this will
   *   prevent the disconnection.
   */
  public function preventDisconnect($state = TRUE) {
    $this->preventDisconnect = !empty($state) ? TRUE : $this->preventDisconnect;
  }

  /**
   * Determine if the session disconnection should be prevented.
   *
   * @return bool
   */
  public function shouldPreventDisconnect() {
    return $this->preventDisconnect;
  }

  /**
   * Get the message the user will see when their session is ended.
   *
   * @return string
   */
  public function getMessage() {
    return $this->message;
  }

  /**
   * Set the message the user sees when their session is ended.
   *
   * @param string $message
   * @return $this
   */
  public function setMessage($message) {
    $this->message = $message;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SessionLimitDisconnectEvent::$collisionEvent protected property
SessionLimitDisconnectEvent::$message protected property
SessionLimitDisconnectEvent::$preventDisconnect protected property
SessionLimitDisconnectEvent::$sessionId protected property
SessionLimitDisconnectEvent::getCollisionEvent public function
SessionLimitDisconnectEvent::getMessage public function Get the message the user will see when their session is ended.
SessionLimitDisconnectEvent::getSessionId public function
SessionLimitDisconnectEvent::preventDisconnect public function Call to prevent the session being disconnected.
SessionLimitDisconnectEvent::setMessage public function Set the message the user sees when their session is ended.
SessionLimitDisconnectEvent::shouldPreventDisconnect public function Determine if the session disconnection should be prevented.
SessionLimitDisconnectEvent::__construct public function SessionLimitCollisionEvent constructor.