configWriter = $configWriter; parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * {@inheritdoc} * * {@inheritdoc}. Set schedule setting for cron. * * @return Value */ public function afterSave() { $result = preg_match('#(?\d{2}),(?\d{2}),(?\d{2})#', $this->getValue(), $time); if (!$result) { throw new LocalizedException( __('The time value is using an unsupported format. Enter a supported format and try again.') ); } $cronExprArray = [ $time['min'], # Minute $time['hour'], # Hour '*', # Day of the Month '*', # Month of the Year '*', # Day of the Week ]; $cronExprString = join(' ', $cronExprArray); try { $this->configWriter->save(self::CRON_SCHEDULE_PATH, $cronExprString); } catch (\Exception $e) { $this->_logger->error($e->getMessage()); throw new LocalizedException(__('Cron settings can\'t be saved')); } return parent::afterSave(); } }