module = $module; $this->tools = $tools; $this->exportProductProcessor = $exportProductProcessor; $this->exportOfferProcessor = $exportOfferProcessor; $this->orderProcessor = $orderProcessor; $this->context = Context::getContext(); } public function handle($action) { set_time_limit(0); switch ($action) { case self::ACTION_EXPORT_PRODUCTS: $this->exportProductProcessor->process(); break; case self::ACTION_EXPORT_OFFERS: $this->exportOfferProcessor->process(); break; case self::ACTION_IMPORT_ORDERS: $this->orderProcessor->process(); break; default: throw new InvalidActionException(); } } public function getAvailableActionsUrls() { $urls = []; foreach (self::ACTIONS as $action) { $urls[$action] = $this->getActionUrl($action); } return $urls; } public function checkToken($token) { return $token === $this->getToken(); } protected function getActionUrl($action) { return $this->context->link->getModuleLink($this->module->name, 'cron', [ 'action' => $action, 'token' => $this->getToken(), ]); } protected function getToken() { return $this->tools->hash($this->module->name . '_cron'); } }