class OatmealCookie in Bakery Single Sign-On System 8.2
Hierarchy
- class \Drupal\bakery\Cookies\OatmealCookie implements CookieInterface uses BrowserCookieTrait
Expanded class hierarchy of OatmealCookie
2 files declare their use of OatmealCookie
- MainDeprecatedController.php in src/
Controller/ MainDeprecatedController.php - OatmealCookieTest.php in tests/
src/ Unit/ Cookies/ OatmealCookieTest.php
File
- src/
Cookies/ OatmealCookie.php, line 5
Namespace
Drupal\bakery\CookiesView source
class OatmealCookie implements CookieInterface {
use BrowserCookieTrait;
protected $calories = 320;
protected $name;
protected $data;
/**
* @var int|null
*/
protected $isMain;
public final function __construct($name, $data, $main = NULL) {
$this->name = $name;
$this->data = $data;
$this->isMain = $main;
}
/**
* {@inheritDoc}
*/
public static function fromData(array $data) {
return new static($data['name'], $data['data'], $data['master'] ?? NULL);
}
/**
* {@inheritDoc}
*/
public function toData() : array {
$main = $this->isMain ?? $this
->getIsMain();
$tmp = [
'name' => $this->name,
'data' => $this->data,
'master' => (int) $main,
'calories' => $this->calories,
];
if (!$main) {
global $base_url;
$tmp['slave'] = $base_url . '/';
}
return $tmp;
}
/**
* {@inheritDoc}
*/
public static function getName() : string {
return static::cookieName('OATMEAL');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BrowserCookieTrait:: |
protected static | function | Wrap cookie name for browser. | |
BrowserCookieTrait:: |
private static | function | Get a kitchen. | |
BrowserCookieTrait:: |
private static | function | Get a bakery service. | |
BrowserCookieTrait:: |
protected | function | Helper to determine if the current site is the "main" site. | |
OatmealCookie:: |
protected | property | ||
OatmealCookie:: |
protected | property | ||
OatmealCookie:: |
protected | property | ||
OatmealCookie:: |
protected | property | ||
OatmealCookie:: |
public static | function |
Create from data stored in a cookie. Overrides CookieInterface:: |
|
OatmealCookie:: |
public static | function |
Get the cookie name/type. Overrides CookieInterface:: |
|
OatmealCookie:: |
public | function |
Convert the data into an array to be stored into a cookie. Overrides CookieInterface:: |
|
OatmealCookie:: |
final public | function |