1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
MarketExpiredPopup.php
См. документацию.
1<?php
2
4
7
8abstract class MarketExpiredPopup
9{
10 private const POPUP_SHOW_DELAY = 60 * 60 * 24; // 1 day
11
12 public function __construct(
13 protected readonly OptionContract $userOption,
14 protected readonly MarketExpiredNotification $marketSubscriptionNotification,
15 )
16 {}
17
18 abstract protected function getOptionPrefix(): string;
19
20 abstract protected function isEnabledForCurrentUser(): bool;
21
22 final public function isReadyToShow(): bool
23 {
24 return $this->marketSubscriptionNotification->isAvailable() && $this->isEnabledForCurrentUser();
25 }
26
27 final public function isDismissedByUser(): bool
28 {
29 return $this->userOption->get($this->getOptionPrefix() . 'Dismiss', 'N') === 'Y';
30 }
31
32 final protected function isTimeToShowForCurrentUser(): bool
33 {
34 $lastShowTimestamp = $this->userOption->get($this->getOptionPrefix() . 'Ts', null);
35
36 if (!is_numeric($lastShowTimestamp) || !$lastShowTimestamp)
37 {
38 return true;
39 }
40
41 return $lastShowTimestamp + self::POPUP_SHOW_DELAY < time();
42 }
43}
__construct(protected readonly OptionContract $userOption, protected readonly MarketExpiredNotification $marketSubscriptionNotification,)
Определения MarketExpiredPopup.php:12