Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Identifier.php
Go to the documentation of this file.
1 <?php
7 
12 {
13  const COOKIE_KEY = 'storage_data_id';
14 
15  const SECTION_KEY = 'data_id';
16 
17  const UPDATE_MARK = 'sections_updated';
18 
22  protected $markId;
23 
27  protected $cookieManager;
28 
32  protected $sessionConfig;
33 
37  public function __construct(
38  \Magento\Framework\Stdlib\Cookie\PhpCookieManager $cookieManager
39  ) {
40  $this->cookieManager = $cookieManager;
41  }
42 
49  public function initMark($forceUpdate)
50  {
51  if ($forceUpdate) {
52  $this->markId = time();
53  return $this->markId;
54  }
55 
56  $cookieMarkId = false;
57  if (!$this->markId) {
58  $cookieMarkId = $this->cookieManager->getCookie(self::COOKIE_KEY);
59  }
60 
61  $this->markId = $cookieMarkId ? $cookieMarkId : time();
62 
63  return $this->markId;
64  }
65 
74  public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
75  {
76  if (!$sectionNames) {
77  $sectionNames = array_keys($sectionsData);
78  }
79  $markId = $this->initMark($updateIds);
80 
81  foreach ($sectionNames as $name) {
82  if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
83  $sectionsData[$name][self::SECTION_KEY] = $markId;
84  }
85  }
86  return $sectionsData;
87  }
88 }
__construct(\Magento\Framework\Stdlib\Cookie\PhpCookieManager $cookieManager)
Definition: Identifier.php:37
markSections(array $sectionsData, $sectionNames=null, $updateIds=false)
Definition: Identifier.php:74
if(!isset($_GET['name'])) $name
Definition: log.php:14