Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SubscriptionStatusProvider.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
21  const ENABLED = "Enabled";
22 
26  const FAILED = "Failed";
27 
31  const PENDING = "Pending";
32 
36  const DISABLED = "Disabled";
37 
41  private $scopeConfig;
42 
46  private $analyticsToken;
47 
51  private $flagManager;
52 
58  public function __construct(
59  ScopeConfigInterface $scopeConfig,
60  AnalyticsToken $analyticsToken,
61  FlagManager $flagManager
62  ) {
63  $this->scopeConfig = $scopeConfig;
64  $this->analyticsToken = $analyticsToken;
65  $this->flagManager = $flagManager;
66  }
67 
79  public function getStatus()
80  {
81  $isSubscriptionEnabledInConfig = $this->scopeConfig->getValue('analytics/subscription/enabled');
82  if ($isSubscriptionEnabledInConfig) {
83  return $this->getStatusForEnabledSubscription();
84  }
85 
86  return $this->getStatusForDisabledSubscription();
87  }
88 
95  {
96  $status = static::ENABLED;
97  if ($this->flagManager->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)) {
99  }
100 
101  if (!$this->analyticsToken->isTokenExist()) {
102  $status = static::PENDING;
103  if ($this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE) === null) {
104  $status = static::FAILED;
105  }
106  }
107 
108  return $status;
109  }
110 
117  {
118  return static::DISABLED;
119  }
120 }
__construct(ScopeConfigInterface $scopeConfig, AnalyticsToken $analyticsToken, FlagManager $flagManager)
$status
Definition: order_status.php:8