cookieManager = $cookieManager; } /** * Init mark(identifier) for sections * * @param bool $forceNewTimestamp * @return int */ public function initMark($forceNewTimestamp) { if ($forceNewTimestamp) { $this->markId = time(); return $this->markId; } $cookieMarkId = false; if (!$this->markId) { $cookieMarkId = $this->cookieManager->getCookie(self::COOKIE_KEY); } $this->markId = $cookieMarkId ? $cookieMarkId : time(); return $this->markId; } /** * Mark sections with data id * * @param array $sectionsData * @param array|null $sectionNames * @param bool $forceNewTimestamp * @return array */ public function markSections(array $sectionsData, $sectionNames = null, $forceNewTimestamp = false) { if (!$sectionNames) { $sectionNames = array_keys($sectionsData); } $markId = $this->initMark($forceNewTimestamp); foreach ($sectionNames as $name) { if ($forceNewTimestamp || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) { $sectionsData[$name][self::SECTION_KEY] = $markId; } } return $sectionsData; } }