33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
use FreshMail\ApiV2\UnauthorizedException;
|
|
use FreshMail\Repository\FreshmailSettings;
|
|
|
|
class AdminFreshmailBaseController extends ModuleAdminController
|
|
{
|
|
protected $freshmail;
|
|
protected $freshmailSettings;
|
|
|
|
public function init()
|
|
{
|
|
$this->freshmailSettings = (new FreshmailSettings())->findForShop($this->context->shop->id);
|
|
|
|
if (!Validate::isLoadedObject(($this->freshmailSettings)) || 0 == $this->freshmailSettings->wizard_completed) {
|
|
$link = $this->context->link->getAdminLink('AdminModules', true, [], ['configure' => $this->module->name]);
|
|
Tools::redirectAdmin($link);
|
|
}
|
|
|
|
if(!empty($this->freshmailSettings->api_token)) {
|
|
$this->freshmail = new \FreshMail\Freshmail($this->freshmailSettings->api_token);
|
|
$response = $this->freshmail->check();
|
|
|
|
if (!$response['status']) {
|
|
$link = $this->context->link->getAdminLink('AdminFreshmailConfig', true, [], ['configure' => $this->module->name]);
|
|
Tools::redirectAdmin($link);
|
|
}
|
|
}
|
|
|
|
return parent::init(); // TODO: Change the autogenerated stub
|
|
}
|
|
|
|
} |