Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SensitiveCookieMetadata.php
Go to the documentation of this file.
1 <?php
8 
10 
21 {
25  protected $request;
26 
31  public function __construct(RequestInterface $request, $metadata = [])
32  {
33  if (!isset($metadata[self::KEY_HTTP_ONLY])) {
34  $metadata[self::KEY_HTTP_ONLY] = true;
35  }
36  $this->request = $request;
37  parent::__construct($metadata);
38  }
39 
43  public function getSecure()
44  {
45  $this->updateSecureValue();
46  return $this->get(self::KEY_SECURE);
47  }
48 
52  public function __toArray()
53  {
54  $this->updateSecureValue();
55  return parent::__toArray();
56  }
57 
63  private function updateSecureValue()
64  {
65  if (null === $this->get(self::KEY_SECURE)) {
66  $this->set(self::KEY_SECURE, $this->request->isSecure());
67  }
68  }
69 }