You are here

public function Kitchen::taste in Bakery Single Sign-On System 8.2

Check that the given cookie exists and doesn't taste funny.

Parameters

string $type: Optional string defining the type of data this is.

\Symfony\Component\HttpFoundation\ParameterBag|null $cookies: Optional list of cookies from the request.

Return value

array|bool Unserialized data or FALSE if invalid.

File

src/Kitchen.php, line 144

Class

Kitchen

Namespace

Drupal\bakery

Code

public function taste(string $type, ParameterBag $cookies = NULL) {
  $cookies = $cookies ?? \Drupal::request()->cookies;
  $cookie_name = $this
    ->cookieName($type);
  if (!$cookies
    ->has($cookie_name)) {
    return FALSE;
  }

  // Shouldn't this be part of baking not tasting?
  if (!$this->config
    ->get('bakery_domain')) {
    return FALSE;
  }
  return $this
    ->tasteData($cookies
    ->get($cookie_name), $cookie_name);
}