You are here

class ChocolateChip in Bakery Single Sign-On System 8.2

Hierarchy

Expanded class hierarchy of ChocolateChip

7 files declare their use of ChocolateChip
BootSubscriber.php in src/EventSubscriber/BootSubscriber.php
For Boot event subscribe.
ChildLoginTest.php in tests/src/Functional/ChildLoginTest.php
ChildSitePagesTest.php in tests/src/Functional/ChildSitePagesTest.php
ChocolateChipTest.php in tests/src/Unit/Cookies/ChocolateChipTest.php
Kitchen.php in src/Kitchen.php

... See full list

File

src/Cookies/ChocolateChip.php, line 5

Namespace

Drupal\bakery\Cookies
View source
class ChocolateChip implements CookieInterface {
  use BrowserCookieTrait;

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

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

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

  /**
   * @var bool|null
   */
  protected $isMain;
  private $calories = 480;
  public final function __construct($name, $mail, $init, $is_main = NULL) {
    $this->name = $name;
    $this->mail = $mail;
    $this->init = $init;
    $this->isMain = $is_main;
  }

  /**
   * {@inheritDoc}
   */
  public static function fromData(array $data) {
    return new static($data['name'] ?? '', $data['mail'] ?? '', $data['init'] ?? '');
  }

  /**
   * {@inheritDoc}
   */
  public function toData() : array {
    return [
      'name' => $this->name,
      'mail' => $this->mail,
      // should this be calculated?
      'init' => $this->init,
      'master' => $this->isMain ?? $this
        ->getIsMain(),
      'calories' => $this->calories,
    ];
  }

  /**
   * {@inheritDoc}
   */
  public static function getName() : string {
    return static::cookieName('CHOCOLATECHIP');
  }
  public function getAccountName() : string {
    return $this->name;
  }
  public function getEmail() : string {
    return $this->mail;
  }
  public function getInit() : string {
    return $this->init;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BrowserCookieTrait::cookieName protected static function Wrap cookie name for browser.
BrowserCookieTrait::getBakeryKitchen private static function Get a kitchen.
BrowserCookieTrait::getBakeryService private static function Get a bakery service.
BrowserCookieTrait::getIsMain protected function Helper to determine if the current site is the "main" site.
ChocolateChip::$calories private property
ChocolateChip::$init protected property
ChocolateChip::$isMain protected property
ChocolateChip::$mail protected property
ChocolateChip::$name protected property
ChocolateChip::fromData public static function Create from data stored in a cookie. Overrides CookieInterface::fromData
ChocolateChip::getAccountName public function
ChocolateChip::getEmail public function
ChocolateChip::getInit public function
ChocolateChip::getName public static function Get the cookie name/type. Overrides CookieInterface::getName
ChocolateChip::toData public function Convert the data into an array to be stored into a cookie. Overrides CookieInterface::toData
ChocolateChip::__construct final public function