68 lines
1.8 KiB
PHP
Executable File
68 lines
1.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace FedEx\Controller;
|
|
|
|
use FedEx\FedEx;
|
|
use FedEx\Model\Config\FedExConfigValue;
|
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
use Thelia\Controller\Admin\BaseAdminController;
|
|
use Thelia\Core\Security\AccessManager;
|
|
use Thelia\Core\Security\Resource\AdminResources;
|
|
use Thelia\Form\Exception\FormValidationException;
|
|
use Thelia\Tools\URL;
|
|
|
|
/**
|
|
* Class Configuration
|
|
* @package FedEx\Controller
|
|
* @author Laurent LE CORRE <laurent@thecoredev.fr>
|
|
*/
|
|
class Configuration extends BaseAdminController
|
|
{
|
|
public function editConfiguration()
|
|
{
|
|
if (null !== $response = $this->checkAuth(
|
|
AdminResources::MODULE,
|
|
[FedEx::DOMAIN_NAME],
|
|
AccessManager::UPDATE
|
|
)) {
|
|
return $response;
|
|
}
|
|
|
|
$form = $this->createForm('fedex.configuration');
|
|
$error_message = null;
|
|
|
|
try {
|
|
$validateForm = $this->validateForm($form);
|
|
$data = $validateForm->getData();
|
|
|
|
FedEx::setConfigValue(
|
|
FedExConfigValue::TRACKING_URL,
|
|
$data["tracking_url"]
|
|
);
|
|
|
|
return $this->redirectToConfigurationPage();
|
|
|
|
} catch (FormValidationException $e) {
|
|
$error_message = $this->createStandardFormValidationErrorMessage($e);
|
|
}
|
|
|
|
if (null !== $error_message) {
|
|
$this->setupFormErrorContext(
|
|
'configuration',
|
|
$error_message,
|
|
$form
|
|
);
|
|
$response = $this->render("module-configure", ['module_code' => 'FedEx']);
|
|
}
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* Redirect to the configuration page
|
|
*/
|
|
protected function redirectToConfigurationPage()
|
|
{
|
|
return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/fedex'));
|
|
}
|
|
}
|