abstract class SocialApiDataHandler in Social API 8.2
Same name and namespace in other branches
- 3.x src/SocialApiDataHandler.php \Drupal\social_api\SocialApiDataHandler
Variables are written to and read from session via this class.
Hierarchy
- class \Drupal\social_api\SocialApiDataHandler
Expanded class hierarchy of SocialApiDataHandler
1 file declares its use of SocialApiDataHandler
- UserAuthenticator.php in src/
User/ UserAuthenticator.php
1 string reference to 'SocialApiDataHandler'
1 service uses SocialApiDataHandler
File
- src/
SocialApiDataHandler.php, line 10
Namespace
Drupal\social_apiView source
abstract class SocialApiDataHandler {
/**
* The session service.
*
* @var \Symfony\Component\HttpFoundation\Session\SessionInterface
*/
protected $session;
/**
* The prefix each session variable will have.
*
* @var string
*/
protected $sessionPrefix;
/**
* Constructor.
*
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
* Used for reading data from and writing data to session.
*/
public function __construct(SessionInterface $session) {
$this->session = $session;
}
/**
* Gets a session variable by key.
*
* @param string $key
* The session variable key.
*
* @return mixed
* The session variable value.
*/
public function get($key) {
return $this->session
->get($this
->getSessionPrefix() . $key);
}
/**
* Sets a new session variable.
*
* @param string $key
* The session variable key.
* @param mixed $value
* The session variable value.
*/
public function set($key, $value) {
$this->session
->set($this
->getSessionPrefix() . $key, $value);
}
/**
* Gets the session prefix for the data handler.
*
* @return string
* The session prefix.
*/
public function getSessionPrefix() {
return $this->sessionPrefix;
}
/**
* Sets the session prefix for the data handler.
*
* @param string $prefix
* The session prefix.
*/
public function setSessionPrefix($prefix) {
$this->sessionPrefix = $prefix . '_';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialApiDataHandler:: |
protected | property | The session service. | |
SocialApiDataHandler:: |
protected | property | The prefix each session variable will have. | |
SocialApiDataHandler:: |
public | function | Gets a session variable by key. | |
SocialApiDataHandler:: |
public | function | Gets the session prefix for the data handler. | |
SocialApiDataHandler:: |
public | function | Sets a new session variable. | |
SocialApiDataHandler:: |
public | function | Sets the session prefix for the data handler. | |
SocialApiDataHandler:: |
public | function | Constructor. |