27 const CRON_STRING_PATH =
'crontab/default/jobs/analytics_subscribe/schedule/cron_expr';
35 '*', # Day of the Month
36 '*', # Month of the Year
37 '*', # Day of the Week
45 private $attemptsInitValue = 24;
52 private $configWriter;
66 private $analyticsToken;
71 private $reinitableConfig;
88 $this->reinitableConfig = $reinitableConfig;
100 if (!$this->analyticsToken->isTokenExist()) {
101 $this->setCronSchedule();
102 $this->setAttemptsFlag();
103 $this->reinitableConfig->reinit();
114 private function setCronSchedule()
116 $this->configWriter->save(self::CRON_STRING_PATH, join(
' ', self::CRON_EXPR_ARRAY));
125 private function setAttemptsFlag()
127 return $this->flagManager
128 ->saveFlag(self::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue);
141 $this->disableCollectionData();
143 if (!$this->analyticsToken->isTokenExist()) {
144 $this->unsetAttemptsFlag();
155 private function unsetAttemptsFlag()
157 return $this->flagManager
158 ->deleteFlag(self::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
166 private function disableCollectionData()
__construct(WriterInterface $configWriter, FlagManager $flagManager, AnalyticsToken $analyticsToken, ReinitableConfigInterface $reinitableConfig)
const ATTEMPTS_REVERSE_COUNTER_FLAG_CODE