Quelques modifs de style front-office
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace StockAlert\Controller;
|
||||
|
||||
|
||||
use StockAlert\StockAlert;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* Class StockAlertBackOfficeController
|
||||
* @package StockAlert\Controller
|
||||
* @author Baixas Alban <abaixas@openstudio.fr>
|
||||
* @author Julien Chanséaume <julien@thelia.net>
|
||||
*/
|
||||
class StockAlertBackOfficeController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function configuration()
|
||||
{
|
||||
$errorMessage = null;
|
||||
|
||||
$form = $this->createForm('stockalert.configuration.form', 'form');
|
||||
|
||||
try {
|
||||
$configForm = $this->validateForm($form)->getData();
|
||||
|
||||
ConfigQuery::write(StockAlert::CONFIG_ENABLED, $configForm['enabled']);
|
||||
ConfigQuery::write(StockAlert::CONFIG_THRESHOLD, $configForm['threshold']);
|
||||
$emails = str_replace(' ', '', $configForm['emails']);
|
||||
ConfigQuery::write(StockAlert::CONFIG_EMAILS, $emails);
|
||||
|
||||
return $this->generateSuccessRedirect($form);
|
||||
} catch (FormValidationException $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
|
||||
$form->setErrorMessage($errorMessage);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($form)
|
||||
->setGeneralError($errorMessage);
|
||||
|
||||
return $this->render(
|
||||
"module-configure",
|
||||
[
|
||||
"module_code" => StockAlert::getModuleCode()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace StockAlert\Controller;
|
||||
|
||||
use StockAlert\Event\StockAlertEvent;
|
||||
use StockAlert\Event\StockAlertEvents;
|
||||
use StockAlert\StockAlert;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
|
||||
/**
|
||||
* Class RestockingAlertFrontOfficeController
|
||||
* @package StockAlert\Controller
|
||||
* @author Baixas Alban <abaixas@openstudio.fr>
|
||||
* @author Julien Chanséaume <julien@thelia.net>
|
||||
*/
|
||||
class StockAlertFrontOfficeController extends BaseFrontController
|
||||
{
|
||||
|
||||
public function subscribe()
|
||||
{
|
||||
$errorMessage = null;
|
||||
|
||||
$form = $this->createForm('stockalert.subscribe.form', 'form');
|
||||
|
||||
try {
|
||||
$subscribeForm = $this->validateForm($form)->getData();
|
||||
|
||||
$subscriberEvent = new StockAlertEvent(
|
||||
$subscribeForm['product_sale_elements_id'],
|
||||
$subscribeForm['email'],
|
||||
$this->getRequest()->getSession()->getLang()->getLocale()
|
||||
);
|
||||
|
||||
$this->dispatch(StockAlertEvents::STOCK_ALERT_SUBSCRIBE, $subscriberEvent);
|
||||
|
||||
return $this->jsonResponse(
|
||||
json_encode(
|
||||
[
|
||||
"success" => true,
|
||||
"message" => $this->getTranslator()->trans(
|
||||
"Your request has been taken into account",
|
||||
[],
|
||||
StockAlert::MESSAGE_DOMAIN
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
} catch (FormValidationException $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
|
||||
return $this->jsonResponse(
|
||||
json_encode(
|
||||
[
|
||||
"success" => false,
|
||||
"message" => $errorMessage
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user