This commit is contained in:
Manuel Raynaud
2013-09-30 10:35:34 +02:00
parent 43b5a129f7
commit c65ec67bdf
168 changed files with 577 additions and 818 deletions

View File

@@ -25,7 +25,6 @@ namespace Thelia\Controller\Admin;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ToggleVisibilityEvent;
/**
* An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object.
@@ -53,14 +52,13 @@ abstract class AbstractCrudController extends BaseAdminController
protected $visibilityToggleEventIdentifier;
protected $changePositionEventIdentifier;
/**
* @param string $objectName the lower case object name. Example. "message"
*
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
* @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable)
*
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
@@ -70,7 +68,7 @@ abstract class AbstractCrudController extends BaseAdminController
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
*
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
*/
public function __construct(
$objectName,
@@ -109,94 +107,93 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Return the creation form for this object
*/
protected abstract function getCreationForm();
abstract protected function getCreationForm();
/**
* Return the update form for this object
*/
protected abstract function getUpdateForm();
abstract protected function getUpdateForm();
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param unknown $object
*/
protected abstract function hydrateObjectForm($object);
abstract protected function hydrateObjectForm($object);
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected abstract function getCreationEvent($formData);
abstract protected function getCreationEvent($formData);
/**
* Creates the update event with the provided form data
*
* @param unknown $formData
*/
protected abstract function getUpdateEvent($formData);
abstract protected function getUpdateEvent($formData);
/**
* Creates the delete event with the provided form data
*/
protected abstract function getDeleteEvent();
abstract protected function getDeleteEvent();
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param unknown $event
*/
protected abstract function eventContainsObject($event);
abstract protected function eventContainsObject($event);
/**
* Get the created object from an event.
*
* @param unknown $createEvent
*/
protected abstract function getObjectFromEvent($event);
abstract protected function getObjectFromEvent($event);
/**
* Load an existing object from the database
*/
protected abstract function getExistingObject();
abstract protected function getExistingObject();
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param unknown $object
*/
protected abstract function getObjectLabel($object);
abstract protected function getObjectLabel($object);
/**
* Returns the object ID from the object
*
* @param unknown $object
*/
protected abstract function getObjectId($object);
abstract protected function getObjectId($object);
/**
* Render the main list template
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected abstract function renderListTemplate($currentOrder);
abstract protected function renderListTemplate($currentOrder);
/**
* Render the edition template
*/
protected abstract function renderEditionTemplate();
abstract protected function renderEditionTemplate();
/**
* Redirect to the edition template
*/
protected abstract function redirectToEditionTemplate();
abstract protected function redirectToEditionTemplate();
/**
* Redirect to the list template
*/
protected abstract function redirectToListTemplate();
abstract protected function redirectToListTemplate();
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
@@ -211,7 +208,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object creation processing if required.
*
* @param unknown $createEvent the create event
* @param unknown $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
@@ -222,7 +219,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object update processing if required.
*
* @param unknown $updateEvent the update event
* @param unknown $updateEvent the update event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalUpdateAction($updateEvent)
@@ -233,7 +230,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object delete processing if required.
*
* @param unknown $deleteEvent the delete event
* @param unknown $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
@@ -244,7 +241,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Put in this method post object position change processing if required.
*
* @param unknown $deleteEvent the delete event
* @param unknown $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalUpdatePositionAction($positionChangeEvent)
@@ -282,7 +279,6 @@ abstract class AbstractCrudController extends BaseAdminController
public function defaultAction()
{
if (null !== $response = $this->checkAuth($this->viewPermissionIdentifier)) return $response;
return $this->renderList();
}
@@ -323,22 +319,19 @@ abstract class AbstractCrudController extends BaseAdminController
$response = $this->performAdditionalCreateAction($createEvent);
if ($response == null) {
if ($response == null) {
// Substitute _ID_ in the URL with the ID of the created object
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
// Redirect to the success URL
$this->redirect($successUrl);
}
else {
} else {
return $response;
}
}
catch (FormValidationException $ex) {
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
@@ -423,16 +416,13 @@ abstract class AbstractCrudController extends BaseAdminController
// Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl());
}
else {
} else {
return $response;
}
}
catch (FormValidationException $ex) {
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
@@ -469,8 +459,7 @@ abstract class AbstractCrudController extends BaseAdminController
$event = $this->createUpdatePositionEvent($mode, $position);
$this->dispatch($this->changePositionEventIdentifier, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -479,14 +468,13 @@ abstract class AbstractCrudController extends BaseAdminController
if ($response == null) {
$this->redirectToListTemplate();
}
else {
} else {
return $response;
}
}
protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true) {
protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true)
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
@@ -507,8 +495,7 @@ abstract class AbstractCrudController extends BaseAdminController
$event = new UpdatePositionEvent($object->getId(), $mode, $position);
$this->dispatch($eventName, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}

View File

@@ -23,10 +23,6 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class AdminController extends BaseAdminController
{
public function indexAction()
@@ -36,6 +32,6 @@ class AdminController extends BaseAdminController
public function updateAction()
{
return $this->render("profile-edit");
return $this->render("profile-edit");
}
}

View File

@@ -193,4 +193,4 @@ class AttributeAvController extends AbstractCrudController
$this->getViewArguments()
);
}
}
}

View File

@@ -113,7 +113,7 @@ class AttributeController extends AbstractCrudController
if ($attr_values !== null) {
foreach($attr_values as $id => $value) {
foreach ($attr_values as $id => $value) {
$event = new AttributeAvUpdateEvent($id);
@@ -168,7 +168,7 @@ class AttributeController extends AbstractCrudController
$attr_array = array();
foreach($attr_av_list as $attr_av) {
foreach ($attr_av_list as $attr_av) {
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
}
@@ -262,8 +262,7 @@ class AttributeController extends AbstractCrudController
$this->dispatch($eventType, $event);
}
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -286,4 +285,4 @@ class AttributeController extends AbstractCrudController
{
return $this->addRemoveFromAllTemplates(TheliaEvents::ATTRIBUTE_ADD_TO_ALL_TEMPLATES);
}
}
}

View File

@@ -293,20 +293,19 @@ class BaseAdminController extends BaseController
return $this->getCurrentEditionLang()->getLocale();
}
/**
* Return the current list order identifier for a given object name,
* updating in using the current request.
*
* @param unknown $objectName the object name (e.g. 'attribute', 'message')
* @param unknown $objectName the object name (e.g. 'attribute', 'message')
* @param unknown $requestParameterName the name of the request parameter that defines the list order
* @param unknown $defaultListOrder the default order to use, if none is defined
* @param string $updateSession if true, the session will be updated with the current order.
* @param unknown $defaultListOrder the default order to use, if none is defined
* @param string $updateSession if true, the session will be updated with the current order.
*
* @return String the current liste order.
*/
protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true) {
protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true)
{
$order = $defaultListOrder;
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName);
@@ -318,7 +317,6 @@ class BaseAdminController extends BaseController
);
if ($updateSession) $this->getSession()->set($orderSessionIdentifier, $order);
return $order;
}
@@ -353,8 +351,8 @@ class BaseAdminController extends BaseController
/** Clear the remember me cookie.
*
*/
protected function clearRememberMeCookie() {
protected function clearRememberMeCookie()
{
$ctp = new CookieTokenProvider();
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');

View File

@@ -24,7 +24,6 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Log\Tlog;
use Thelia\Core\Event\Category\CategoryDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Category\CategoryUpdateEvent;
@@ -36,7 +35,6 @@ use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\Category\CategoryDeleteContentEvent;
use Thelia\Core\Event\Category\CategoryAddContentEvent;
use Thelia\Model\CategoryAssociatedContent;
use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery;
use Propel\Runtime\ActiveQuery\Criteria;
@@ -49,7 +47,8 @@ use Thelia\Model\CategoryAssociatedContentQuery;
*/
class CategoryController extends AbstractCrudController
{
public function __construct() {
public function __construct()
{
parent::__construct(
'category',
'manual',
@@ -68,15 +67,18 @@ class CategoryController extends AbstractCrudController
);
}
protected function getCreationForm() {
protected function getCreationForm()
{
return new CategoryCreationForm($this->getRequest());
}
protected function getUpdateForm() {
protected function getUpdateForm()
{
return new CategoryModificationForm($this->getRequest());
}
protected function getCreationEvent($formData) {
protected function getCreationEvent($formData)
{
$createEvent = new CategoryCreateEvent();
$createEvent
@@ -89,7 +91,8 @@ class CategoryController extends AbstractCrudController
return $createEvent;
}
protected function getUpdateEvent($formData) {
protected function getUpdateEvent($formData)
{
$changeEvent = new CategoryUpdateEvent($formData['id']);
// Create and dispatch the change event
@@ -107,8 +110,8 @@ class CategoryController extends AbstractCrudController
return $changeEvent;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('category_id', null),
$positionChangeMode,
@@ -116,16 +119,18 @@ class CategoryController extends AbstractCrudController
);
}
protected function getDeleteEvent() {
protected function getDeleteEvent()
{
return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0));
}
protected function eventContainsObject($event) {
protected function eventContainsObject($event)
{
return $event->hasCategory();
}
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -143,21 +148,25 @@ class CategoryController extends AbstractCrudController
return new CategoryModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
protected function getObjectFromEvent($event)
{
return $event->hasCategory() ? $event->getCategory() : null;
}
protected function getExistingObject() {
protected function getExistingObject()
{
return CategoryQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('category_id', 0));
}
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getTitle();
}
protected function getObjectId($object) {
protected function getObjectId($object)
{
return $object->getId();
}
@@ -170,8 +179,8 @@ class CategoryController extends AbstractCrudController
);
}
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
// Get product order
$product_order = $this->getListOrderFromSession('product', 'product_order', 'manual');
@@ -183,19 +192,21 @@ class CategoryController extends AbstractCrudController
));
}
protected function redirectToListTemplate() {
protected function redirectToListTemplate()
{
$this->redirectToRoute(
'admin.categories.default',
array('category_id' => $this->getRequest()->get('category_id', 0))
);
}
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('category-edit', $this->getEditionArguments());
}
protected function redirectToEditionTemplate() {
protected function redirectToEditionTemplate()
{
$this->redirectToRoute("admin.categories.update", $this->getEditionArguments());
}
@@ -257,8 +268,8 @@ class CategoryController extends AbstractCrudController
return null;
}
public function getAvailableRelatedContentAction($categoryId, $folderId) {
public function getAvailableRelatedContentAction($categoryId, $folderId)
{
$result = array();
$folders = FolderQuery::create()->filterById($folderId)->find();
@@ -273,7 +284,7 @@ class CategoryController extends AbstractCrudController
;
if ($list !== null) {
foreach($list as $item) {
foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
}
}
@@ -282,8 +293,8 @@ class CategoryController extends AbstractCrudController
return $this->jsonResponse(json_encode($result));
}
public function addRelatedContentAction() {
public function addRelatedContentAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -298,8 +309,7 @@ class CategoryController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -341,8 +351,8 @@ class CategoryController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteRelatedContentAction() {
public function deleteRelatedContentAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -357,8 +367,7 @@ class CategoryController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Event\Config\ConfigCreateEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Form\ConfigModificationForm;
use Thelia\Form\ConfigCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
/**
* Manages variables
@@ -39,7 +38,8 @@ use Thelia\Core\Event\UpdatePositionEvent;
*/
class ConfigController extends AbstractCrudController
{
public function __construct() {
public function __construct()
{
parent::__construct(
'variable',
'name',
@@ -58,15 +58,18 @@ class ConfigController extends AbstractCrudController
);
}
protected function getCreationForm() {
protected function getCreationForm()
{
return new ConfigCreationForm($this->getRequest());
}
protected function getUpdateForm() {
protected function getUpdateForm()
{
return new ConfigModificationForm($this->getRequest());
}
protected function getCreationEvent($data) {
protected function getCreationEvent($data)
{
$createEvent = new ConfigCreateEvent();
$createEvent
@@ -78,11 +81,11 @@ class ConfigController extends AbstractCrudController
->setSecured($data['secured'])
;
return $createEvent;
}
protected function getUpdateEvent($data) {
protected function getUpdateEvent($data)
{
$changeEvent = new ConfigUpdateEvent($data['id']);
// Create and dispatch the change event
@@ -101,16 +104,18 @@ class ConfigController extends AbstractCrudController
return $changeEvent;
}
protected function getDeleteEvent() {
protected function getDeleteEvent()
{
return new ConfigDeleteEvent($this->getRequest()->get('variable_id'));
}
protected function eventContainsObject($event) {
protected function eventContainsObject($event)
{
return $event->hasConfig();
}
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -129,40 +134,48 @@ class ConfigController extends AbstractCrudController
return new ConfigModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
protected function getObjectFromEvent($event)
{
return $event->hasConfig() ? $event->getConfig() : null;
}
protected function getExistingObject() {
protected function getExistingObject()
{
return ConfigQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('variable_id'));
}
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getName();
}
protected function getObjectId($object) {
protected function getObjectId($object)
{
return $object->getId();
}
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
return $this->render('variables', array('order' => $currentOrder));
}
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('variable-edit', array('variable_id' => $this->getRequest()->get('variable_id')));
}
protected function redirectToEditionTemplate() {
protected function redirectToEditionTemplate()
{
$this->redirectToRoute(
"admin.configuration.variables.update",
array('variable_id' => $this->getRequest()->get('variable_id'))
);
}
protected function redirectToListTemplate() {
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.variables.default');
}
@@ -188,4 +201,4 @@ class ConfigController extends AbstractCrudController
$this->redirectToRoute('admin.configuration.variables.default');
}
}
}

View File

@@ -32,7 +32,6 @@ use Thelia\Form\ContentCreationForm;
use Thelia\Form\ContentModificationForm;
use Thelia\Model\ContentQuery;
/**
* Class ContentController
* @package Thelia\Controller\Admin
@@ -212,10 +211,10 @@ class ContentController extends AbstractCrudController
{
$folderId = $this->getRequest()->get('folder_id', null);
if(null === $folderId) {
if (null === $folderId) {
$content = $this->getExistingObject();
if($content) {
if ($content) {
$folderId = $content->getDefaultFolderId();
}
}
@@ -275,7 +274,7 @@ class ContentController extends AbstractCrudController
}
/**
* @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent
* @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent
* @return Response|void
*/
protected function performAdditionalUpdateAction($updateEvent)
@@ -293,8 +292,8 @@ class ContentController extends AbstractCrudController
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
* @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
@@ -344,4 +343,4 @@ class ContentController extends AbstractCrudController
{
return new ContentToggleVisibilityEvent($this->getExistingObject());
}
}
}

View File

@@ -43,10 +43,10 @@ class CountryController extends BaseAdminController
* @return mixed|\Symfony\Component\HttpFoundation\Response
*/
public function updateAction($country_id)
{
{
return $this->render("country-edit", array(
"country_id" => $country_id
));
}
}
}

View File

@@ -31,7 +31,6 @@ use Thelia\Core\Event\Condition\ConditionCreateOrUpdateEvent;
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\CouponManager;
use Thelia\Coupon\ConditionCollection;
use Thelia\Coupon\Type\CouponInterface;
@@ -299,7 +298,6 @@ var_dump($coupon->getIsRemovingPostage());;
);
}
/**
* Manage Coupons read display
*
@@ -613,6 +611,4 @@ var_dump($coupon->getIsRemovingPostage());;
// }
// }
}

View File

@@ -39,7 +39,8 @@ use Thelia\Core\Event\UpdatePositionEvent;
*/
class CurrencyController extends AbstractCrudController
{
public function __construct() {
public function __construct()
{
parent::__construct(
'currency',
'manual',
@@ -58,15 +59,18 @@ class CurrencyController extends AbstractCrudController
);
}
protected function getCreationForm() {
protected function getCreationForm()
{
return new CurrencyCreationForm($this->getRequest());
}
protected function getUpdateForm() {
protected function getUpdateForm()
{
return new CurrencyModificationForm($this->getRequest());
}
protected function getCreationEvent($formData) {
protected function getCreationEvent($formData)
{
$createEvent = new CurrencyCreateEvent();
$createEvent
@@ -80,7 +84,8 @@ class CurrencyController extends AbstractCrudController
return $createEvent;
}
protected function getUpdateEvent($formData) {
protected function getUpdateEvent($formData)
{
$changeEvent = new CurrencyUpdateEvent($formData['id']);
// Create and dispatch the change event
@@ -95,8 +100,8 @@ class CurrencyController extends AbstractCrudController
return $changeEvent;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('currency_id', null),
$positionChangeMode,
@@ -104,16 +109,18 @@ class CurrencyController extends AbstractCrudController
);
}
protected function getDeleteEvent() {
protected function getDeleteEvent()
{
return new CurrencyDeleteEvent($this->getRequest()->get('currency_id'));
}
protected function eventContainsObject($event) {
protected function eventContainsObject($event)
{
return $event->hasCurrency();
}
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -128,44 +135,51 @@ class CurrencyController extends AbstractCrudController
return new CurrencyModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
protected function getObjectFromEvent($event)
{
return $event->hasCurrency() ? $event->getCurrency() : null;
}
protected function getExistingObject() {
protected function getExistingObject()
{
return CurrencyQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('currency_id'));
}
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getName();
}
protected function getObjectId($object) {
protected function getObjectId($object)
{
return $object->getId();
}
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
return $this->render('currencies', array('order' => $currentOrder));
}
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('currency-edit', array('currency_id' => $this->getRequest()->get('currency_id')));
}
protected function redirectToEditionTemplate() {
protected function redirectToEditionTemplate()
{
$this->redirectToRoute(
"admin.configuration.currencies.update",
array('currency_id' => $this->getRequest()->get('currency_id'))
);
}
protected function redirectToListTemplate() {
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.currencies.default');
}
/**
* Update currencies rates
*/

View File

@@ -48,10 +48,9 @@ class CustomerController extends BaseAdminController
public function viewAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
/**
@@ -71,7 +70,7 @@ class CustomerController extends BaseAdminController
try {
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
if (null === $customer) {
throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id));
}
@@ -86,7 +85,7 @@ class CustomerController extends BaseAdminController
$this->adminLogAppend(sprintf("Customer with Ref %s (ID %d) modified", $customerUpdated->getRef() , $customerUpdated->getId()));
if($this->getRequest()->get("save_mode") == "close") {
if ($this->getRequest()->get("save_mode") == "close") {
$this->redirectToRoute("admin.customers");
} else {
$this->redirectSuccess($customerModification);
@@ -126,14 +125,14 @@ class CustomerController extends BaseAdminController
$customer_id = $this->getRequest()->get("customer_id");
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
if (null === $customer) {
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exist"));
}
$event = new CustomerEvent($customer);
$this->dispatch(TheliaEvents::CUSTOMER_DELETEACCOUNT, $event);
} catch(\Exception $e) {
} catch (\Exception $e) {
$message = $e->getMessage();
}
@@ -178,4 +177,4 @@ class CustomerController extends BaseAdminController
return $customerCreateEvent;
}
}
}

View File

@@ -193,4 +193,4 @@ class FeatureAvController extends AbstractCrudController
$this->getViewArguments()
);
}
}
}

View File

@@ -113,7 +113,7 @@ class FeatureController extends AbstractCrudController
if ($attr_values !== null) {
foreach($attr_values as $id => $value) {
foreach ($attr_values as $id => $value) {
$event = new FeatureAvUpdateEvent($id);
@@ -168,7 +168,7 @@ class FeatureController extends AbstractCrudController
$attr_array = array();
foreach($attr_av_list as $attr_av) {
foreach ($attr_av_list as $attr_av) {
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
}
@@ -262,8 +262,7 @@ class FeatureController extends AbstractCrudController
$this->dispatch($eventType, $event);
}
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -286,4 +285,4 @@ class FeatureController extends AbstractCrudController
{
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES);
}
}
}

View File

@@ -25,15 +25,12 @@ namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Document\DocumentDeleteEvent;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\Image\ImageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryDocument;
@@ -62,7 +59,6 @@ use Thelia\Tools\Rest\ResponseRest;
class FileController extends BaseAdminController
{
/**
* Manage how a image collection has to be saved
*
@@ -126,14 +122,12 @@ class FileController extends BaseAdminController
$imageCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
$imageCreateOrUpdateEvent->setParentName($parentModel->getTitle());
// Dispatch Event to the Action
$this->dispatch(
TheliaEvents::IMAGE_SAVE,
$imageCreateOrUpdateEvent
);
return new ResponseRest(array('status' => true, 'message' => ''));
}
}
@@ -192,14 +186,12 @@ class FileController extends BaseAdminController
$documentCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
$documentCreateOrUpdateEvent->setParentName($parentModel->getTitle());
// Dispatch Event to the Action
$this->dispatch(
TheliaEvents::DOCUMENT_SAVE,
$documentCreateOrUpdateEvent
);
return new ResponseRest(array('status' => true, 'message' => ''));
}
}
@@ -676,5 +668,4 @@ class FileController extends BaseAdminController
return $documentCreateEvent;
}
}

View File

@@ -81,8 +81,8 @@ class FolderController extends AbstractCrudController
*
* @param \Thelia\Model\Folder $object
*/
protected function hydrateObjectForm($object) {
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -162,8 +162,8 @@ class FolderController extends AbstractCrudController
* @param $positionValue
* @return UpdatePositionEvent|void
*/
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('folder_id', null),
$positionChangeMode,
@@ -196,7 +196,8 @@ class FolderController extends AbstractCrudController
/**
* Load an existing object from the database
*/
protected function getExistingObject() {
protected function getExistingObject()
{
return FolderQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('folder_id', 0));
@@ -207,7 +208,8 @@ class FolderController extends AbstractCrudController
*
* @param unknown $object
*/
protected function getObjectLabel($object) {
protected function getObjectLabel($object)
{
return $object->getTitle();
}
@@ -226,8 +228,8 @@ class FolderController extends AbstractCrudController
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected function renderListTemplate($currentOrder) {
protected function renderListTemplate($currentOrder)
{
// Get content order
$content_order = $this->getListOrderFromSession('content', 'content_order', 'manual');
@@ -239,12 +241,11 @@ class FolderController extends AbstractCrudController
));
}
/**
* Render the edition template
*/
protected function renderEditionTemplate() {
protected function renderEditionTemplate()
{
return $this->render('folder-edit', $this->getEditionArguments());
}
@@ -257,7 +258,7 @@ class FolderController extends AbstractCrudController
}
/**
* @param \Thelia\Core\Event\Folder\FolderUpdateEvent $updateEvent
* @param \Thelia\Core\Event\Folder\FolderUpdateEvent $updateEvent
* @return Response|void
*/
protected function performAdditionalUpdateAction($updateEvent)
@@ -275,8 +276,8 @@ class FolderController extends AbstractCrudController
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\Folder\FolderDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
* @param \Thelia\Core\Event\Folder\FolderDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
@@ -325,4 +326,4 @@ class FolderController extends AbstractCrudController
array('parent' => $this->getRequest()->get('parent', 0))
);
}
}
}

View File

@@ -35,12 +35,11 @@ class ModuleController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.module.view")) return $response;
return $this->render("modules", array("display_module" => 20));
}
public function updateAction($module_id)
{
return $this->render("module-edit", array(
"module_id" => $module_id
));
return $this->render("module-edit", array(
"module_id" => $module_id
));
}
}
}

View File

@@ -26,7 +26,6 @@ namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Form\OrderUpdateAddress;
use Thelia\Model\Base\OrderAddressQuery;
use Thelia\Model\OrderQuery;
@@ -48,10 +47,9 @@ class OrderController extends BaseAdminController
public function viewAction($order_id)
{
return $this->render("order-edit", array(
"order_id" => $order_id
));
return $this->render("order-edit", array(
"order_id" => $order_id
));
}
public function updateStatus($order_id = null)
@@ -61,7 +59,7 @@ class OrderController extends BaseAdminController
$message = null;
try {
if($order_id !== null) {
if ($order_id !== null) {
$order_id = $order_id;
} else {
$order_id = $this->getRequest()->get("order_id");
@@ -72,10 +70,10 @@ class OrderController extends BaseAdminController
$statusId = $this->getRequest()->request->get("status_id");
$status = OrderStatusQuery::create()->findPk($statusId);
if(null === $order) {
if (null === $order) {
throw new \InvalidArgumentException("The order you want to update status does not exist");
}
if(null === $status) {
if (null === $status) {
throw new \InvalidArgumentException("The status you want to set to the order does not exist");
}
@@ -83,7 +81,7 @@ class OrderController extends BaseAdminController
$event->setStatus($statusId);
$this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
} catch(\Exception $e) {
} catch (\Exception $e) {
$message = $e->getMessage();
}
@@ -95,7 +93,7 @@ class OrderController extends BaseAdminController
$browsedPage = $this->getRequest()->get("order_page");
if($browsedPage) {
if ($browsedPage) {
$params["order_page"] = $browsedPage;
$this->redirectToRoute("admin.order.list", $params);
} else {
@@ -116,7 +114,7 @@ class OrderController extends BaseAdminController
$deliveryRef = $this->getRequest()->get("delivery_ref");
if(null === $order) {
if (null === $order) {
throw new \InvalidArgumentException("The order you want to update status does not exist");
}
@@ -124,7 +122,7 @@ class OrderController extends BaseAdminController
$event->setDeliveryRef($deliveryRef);
$this->dispatch(TheliaEvents::ORDER_UPDATE_DELIVERY_REF, $event);
} catch(\Exception $e) {
} catch (\Exception $e) {
$message = $e->getMessage();
}
@@ -151,7 +149,7 @@ class OrderController extends BaseAdminController
try {
$order = OrderQuery::create()->findPk($order_id);
if(null === $order) {
if (null === $order) {
throw new \InvalidArgumentException("The order you want to update does not exist");
}
@@ -159,7 +157,7 @@ class OrderController extends BaseAdminController
$orderAddress = OrderAddressQuery::create()->findPk($form->get("id")->getData());
if($orderAddress->getId() !== $order->getInvoiceOrderAddressId() && $orderAddress->getId() !== $order->getDeliveryOrderAddressId()) {
if ($orderAddress->getId() !== $order->getInvoiceOrderAddressId() && $orderAddress->getId() !== $order->getDeliveryOrderAddressId()) {
throw new \InvalidArgumentException("The order address you want to update does not belong to the current order not exist");
}
@@ -180,7 +178,7 @@ class OrderController extends BaseAdminController
$event->setOrder($order);
$this->dispatch(TheliaEvents::ORDER_UPDATE_ADDRESS, $event);
} catch(\Exception $e) {
} catch (\Exception $e) {
$message = $e->getMessage();
}
@@ -195,4 +193,4 @@ class OrderController extends BaseAdminController
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
}
}
}

View File

@@ -34,7 +34,6 @@ use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Product\ProductToggleVisibilityEvent;
use Thelia\Core\Event\Product\ProductDeleteContentEvent;
use Thelia\Core\Event\Product\ProductAddContentEvent;
use Thelia\Model\ProductAssociatedContent;
use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery;
use Propel\Runtime\ActiveQuery\Criteria;
@@ -76,8 +75,8 @@ class ProductController extends AbstractCrudController
/**
* Attributes ajax tab loading
*/
public function loadAttributesAjaxTabAction() {
public function loadAttributesAjaxTabAction()
{
return $this->render(
'ajax/product-attributes-tab',
array(
@@ -89,8 +88,8 @@ class ProductController extends AbstractCrudController
/**
* Related information ajax tab loading
*/
public function loadRelatedAjaxTabAction() {
public function loadRelatedAjaxTabAction()
{
return $this->render(
'ajax/product-related-tab',
array(
@@ -229,7 +228,8 @@ class ProductController extends AbstractCrudController
);
}
protected function getCategoryId() {
protected function getCategoryId()
{
// Trouver le category_id, soit depuis la reques, souit depuis le produit courant
$category_id = $this->getRequest()->get('category_id', null);
@@ -340,7 +340,7 @@ class ProductController extends AbstractCrudController
;
if ($list !== null) {
foreach($list as $item) {
foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
}
}
@@ -366,8 +366,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -393,8 +392,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -403,7 +401,6 @@ class ProductController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
// -- Accessories management ----------------------------------------------
public function getAvailableAccessoriesAction($productId, $categoryId)
@@ -422,7 +419,7 @@ class ProductController extends AbstractCrudController
;
if ($list !== null) {
foreach($list as $item) {
foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
}
}
@@ -447,8 +444,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -473,8 +469,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -514,7 +509,8 @@ class ProductController extends AbstractCrudController
*
* @param unknown $productId
*/
public function setProductTemplateAction($productId) {
public function setProductTemplateAction($productId)
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.products.update')) return $response;
@@ -536,8 +532,8 @@ class ProductController extends AbstractCrudController
/**
* Update product attributes and features
*/
public function updateAttributesAndFeaturesAction($productId) {
public function updateAttributesAndFeaturesAction($productId)
{
$product = ProductQuery::create()->findPk($productId);
if ($product != null) {
@@ -556,7 +552,7 @@ class ProductController extends AbstractCrudController
// Update all features values, starting with feature av. values
$featureValues = $this->getRequest()->get('feature_value', array());
foreach($featureValues as $featureId => $featureValueList) {
foreach ($featureValues as $featureId => $featureValueList) {
// Delete all features av. for this feature.
$event = new FeatureProductDeleteEvent($productId, $featureId);
@@ -564,7 +560,7 @@ class ProductController extends AbstractCrudController
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event);
// Add then all selected values
foreach($featureValueList as $featureValue) {
foreach ($featureValueList as $featureValue) {
$event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue);
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event);
@@ -576,7 +572,7 @@ class ProductController extends AbstractCrudController
// Update then features text values
$featureTextValues = $this->getRequest()->get('feature_text_value', array());
foreach($featureTextValues as $featureId => $featureValue) {
foreach ($featureTextValues as $featureId => $featureValue) {
// considere empty text as empty feature value (e.g., we will delete it)
if (empty($featureValue)) continue;
@@ -589,7 +585,7 @@ class ProductController extends AbstractCrudController
}
// Delete features which don't have any values
foreach($allFeatures as $feature) {
foreach ($allFeatures as $feature) {
if (! in_array($feature->getId(), $updatedFeatures)) {
$event = new FeatureProductDeleteEvent($productId, $feature->getId());
@@ -610,8 +606,8 @@ class ProductController extends AbstractCrudController
$this->redirectToListTemplate();
}
public function addAdditionalCategoryAction() {
public function addAdditionalCategoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -626,8 +622,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_CATEGORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -636,8 +631,8 @@ class ProductController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteAdditionalCategoryAction() {
public function deleteAdditionalCategoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -652,8 +647,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CATEGORY, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -664,8 +658,8 @@ class ProductController extends AbstractCrudController
// -- Product combination management ---------------------------------------
public function getAttributeValuesAction($productId, $attributeId) {
public function getAttributeValuesAction($productId, $attributeId)
{
$result = array();
// Get attribute for this product
@@ -680,7 +674,7 @@ class ProductController extends AbstractCrudController
;
if ($values !== null) {
foreach($values as $value) {
foreach ($values as $value) {
$result[] = array('id' => $value->getId(), 'title' => $value->getTitle());
}
}
@@ -689,8 +683,8 @@ class ProductController extends AbstractCrudController
return $this->jsonResponse(json_encode($result));
}
public function addAttributeValueToCombinationAction($productId, $attributeAvId, $combination) {
public function addAttributeValueToCombinationAction($productId, $attributeAvId, $combination)
{
$result = array();
// Get attribute for this product
@@ -734,8 +728,8 @@ class ProductController extends AbstractCrudController
/**
* A a new combination to a product
*/
public function addCombinationAction() {
public function addCombinationAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -747,8 +741,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_COMBINATION, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
@@ -760,8 +753,8 @@ class ProductController extends AbstractCrudController
/**
* A a new combination to a product
*/
public function deleteCombinationAction() {
public function deleteCombinationAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -772,8 +765,7 @@ class ProductController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::PRODUCT_DELETE_COMBINATION, $event);
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}

View File

@@ -31,9 +31,7 @@ use Thelia\Tools\URL;
use Thelia\Tools\Redirect;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Core\Security\UserProvider\TokenProvider;
use Symfony\Component\HttpFoundation\Cookie;
use Thelia\Core\Security\UserProvider\CookieTokenProvider;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class SessionController extends BaseAdminController
@@ -59,8 +57,7 @@ class SessionController extends BaseAdminController
// Render the home page
return $this->render("home");
}
catch (TokenAuthenticationException $ex) {
} catch (TokenAuthenticationException $ex) {
$this->adminLogAppend("Token based authentication failed.");
// Clear the cookie

View File

@@ -35,12 +35,11 @@ class ShippingConfigurationController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response;
return $this->render("shipping-configuration", array("display_shipping_configuration" => 20));
}
public function updateAction($shipping_configuration_id)
{
return $this->render("shipping-configuration-edit", array(
"shipping_configuration_id" => $shipping_configuration_id
));
}
}
}

View File

@@ -35,12 +35,11 @@ class ShippingZoneController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
return $this->render("shipping-zones", array("display_shipping_zone" => 20));
}
public function updateAction($shipping_zones_id)
{
return $this->render("shipping-zones-edit", array(
"shipping_zones_id" => $shipping_zones_id
));
return $this->render("shipping-zones-edit", array(
"shipping_zones_id" => $shipping_zones_id
));
}
}
}

View File

@@ -30,10 +30,6 @@ use Thelia\Core\Event\Template\TemplateCreateEvent;
use Thelia\Model\TemplateQuery;
use Thelia\Form\TemplateModificationForm;
use Thelia\Form\TemplateCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\TemplateAv;
use Thelia\Model\TemplateAvQuery;
use Thelia\Core\Event\Template\TemplateEvent;
use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent;
use Thelia\Core\Event\Template\TemplateAddAttributeEvent;
use Thelia\Core\Event\Template\TemplateAddFeatureEvent;
@@ -41,7 +37,6 @@ use Thelia\Core\Event\Template\TemplateDeleteFeatureEvent;
use Thelia\Model\FeatureTemplateQuery;
use Thelia\Model\AttributeTemplateQuery;
/**
* Manages product templates
*
@@ -102,7 +97,6 @@ class TemplateController extends AbstractCrudController
;
// Add feature and attributes list
return $changeEvent;
}
@@ -199,22 +193,24 @@ class TemplateController extends AbstractCrudController
return null;
}
public function getAjaxFeaturesAction() {
public function getAjaxFeaturesAction()
{
return $this->render(
'ajax/template-feature-list',
array('template_id' => $this->getRequest()->get('template_id'))
);
}
public function getAjaxAttributesAction() {
public function getAjaxAttributesAction()
{
return $this->render(
'ajax/template-attribute-list',
array('template_id' => $this->getRequest()->get('template_id'))
);
}
public function addAttributeAction() {
public function addAttributeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
@@ -237,8 +233,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteAttributeAction() {
public function deleteAttributeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
@@ -257,8 +253,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function updateAttributePositionAction() {
public function updateAttributePositionAction()
{
// Find attribute_template
$attributeTemplate = AttributeTemplateQuery::create()
->filterByTemplateId($this->getRequest()->get('template_id', null))
@@ -272,8 +268,8 @@ class TemplateController extends AbstractCrudController
);
}
public function addFeatureAction() {
public function addFeatureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
@@ -296,8 +292,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function deleteFeatureAction() {
public function deleteFeatureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
@@ -316,8 +312,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
public function updateFeaturePositionAction() {
public function updateFeaturePositionAction()
{
// Find feature_template
$featureTemplate = FeatureTemplateQuery::create()
->filterByTemplateId($this->getRequest()->get('template_id', null))
@@ -330,4 +326,4 @@ class TemplateController extends AbstractCrudController
TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION
);
}
}
}