Merge branch 'master' of github.com:thelia/thelia

This commit is contained in:
Manuel Raynaud
2013-09-12 15:41:04 +02:00
11 changed files with 237 additions and 198 deletions

View File

@@ -25,29 +25,27 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Model\AttributeQuery;
use Thelia\Model\Attribute as AttributeModel;
use Thelia\Model\AttributeAvQuery;
use Thelia\Model\AttributeAv as AttributeAvModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeUpdateEvent;
use Thelia\Core\Event\AttributeCreateEvent;
use Thelia\Core\Event\AttributeDeleteEvent;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeAvCreateEvent;
use Thelia\Core\Event\AttributeAvDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\UpdatePositionEvent;
class Attribute extends BaseAction implements EventSubscriberInterface
class AttributeAv extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new attribute entry
*
* @param AttributeCreateEvent $event
* @param AttributeAvCreateEvent $event
*/
public function create(AttributeCreateEvent $event)
public function create(AttributeAvCreateEvent $event)
{
$attribute = new AttributeModel();
$attribute = new AttributeAvModel();
$attribute
->setDispatcher($this->getDispatcher())
@@ -58,7 +56,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface
->save()
;
$event->setAttribute($attribute);
$event->setAttributeAv($attribute);
// Add atribute to all product templates if required
if ($event->getAddToAllTemplates() != 0) {
@@ -69,13 +67,13 @@ class Attribute extends BaseAction implements EventSubscriberInterface
/**
* Change a product attribute
*
* @param AttributeUpdateEvent $event
* @param AttributeAvUpdateEvent $event
*/
public function update(AttributeUpdateEvent $event)
public function update(AttributeAvUpdateEvent $event)
{
$search = AttributeQuery::create();
$search = AttributeAvQuery::create();
if (null !== $attribute = AttributeQuery::create()->findPk($event->getAttributeId())) {
if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId())) {
$attribute
->setDispatcher($this->getDispatcher())
@@ -88,26 +86,26 @@ class Attribute extends BaseAction implements EventSubscriberInterface
->save();
$event->setAttribute($attribute);
$event->setAttributeAv($attribute);
}
}
/**
* Delete a product attribute entry
*
* @param AttributeDeleteEvent $event
* @param AttributeAvDeleteEvent $event
*/
public function delete(AttributeDeleteEvent $event)
public function delete(AttributeAvDeleteEvent $event)
{
if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) {
if (null !== ($attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId()))) {
$attribute
->setDispatcher($this->getDispatcher())
->delete()
;
$event->setAttribute($attribute);
$event->setAttributeAv($attribute);
}
}
@@ -118,7 +116,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface
*/
public function updatePosition(UpdatePositionEvent $event)
{
if (null !== $attribute = AttributeQuery::create()->findPk($event->getObjectId())) {
if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getObjectId())) {
$attribute->setDispatcher($this->getDispatcher());
@@ -140,10 +138,10 @@ class Attribute extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
TheliaEvents::ATTRIBUTE_CREATE => array("create", 128),
TheliaEvents::ATTRIBUTE_UPDATE => array("update", 128),
TheliaEvents::ATTRIBUTE_DELETE => array("delete", 128),
TheliaEvents::ATTRIBUTE_UPDATE_POSITION => array("updatePosition", 128),
TheliaEvents::ATTRIBUTE_AV_CREATE => array("create", 128),
TheliaEvents::ATTRIBUTE_AV_UPDATE => array("update", 128),
TheliaEvents::ATTRIBUTE_AV_DELETE => array("delete", 128),
TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128),
);
}
}

View File

@@ -62,6 +62,11 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.pageNotFound" class="Thelia\Action\PageNotFound">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>

View File

@@ -68,11 +68,11 @@
</route>
<route id="admin.categories.update" path="/admin/categories/update">
<default key="_controller">Thelia\Controller\Admin\CategoryController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\CategoryController::updateAction</default>
</route>
<route id="admin.categories.save" path="/admin/categories/save">
<default key="_controller">Thelia\Controller\Admin\CategoryController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\CategoryController::processUpdateAction</default>
</route>
<route id="admin.categories.set-default" path="/admin/categories/toggle-online">
@@ -129,11 +129,11 @@
</route>
<route id="admin.configuration.variables.update" path="/admin/configuration/variables/update">
<default key="_controller">Thelia\Controller\Admin\ConfigController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\ConfigController::updateAction</default>
</route>
<route id="admin.configuration.variables.save" path="/admin/configuration/variables/save">
<default key="_controller">Thelia\Controller\Admin\ConfigController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\ConfigController::processUpdateAction</default>
</route>
<route id="admin.configuration.variables.delete" path="/admin/configuration/variables/delete">
@@ -151,11 +151,11 @@
</route>
<route id="admin.configuration.messages.update" path="/admin/configuration/messages/update">
<default key="_controller">Thelia\Controller\Admin\MessageController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\MessageController::updateAction</default>
</route>
<route id="admin.configuration.messages.save" path="/admin/configuration/messages/save">
<default key="_controller">Thelia\Controller\Admin\MessageController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\MessageController::processUpdateAction</default>
</route>
<route id="admin.configuration.messages.delete" path="/admin/configuration/messages/delete">
@@ -173,11 +173,11 @@
</route>
<route id="admin.configuration.currencies.update" path="/admin/configuration/currencies/update">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updateAction</default>
</route>
<route id="admin.configuration.currencies.save" path="/admin/configuration/currencies/save">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\CurrencyController::processUpdateAction</default>
</route>
<route id="admin.configuration.currencies.set-default" path="/admin/configuration/currencies/set-default">
@@ -200,7 +200,8 @@
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
</route>
<!-- attribute and feature routes management -->
<!-- attribute and attributes value management -->
<route id="admin.configuration.attributes.default" path="/admin/configuration/attributes">
<default key="_controller">Thelia\Controller\Admin\AttributeController::defaultAction</default>
@@ -210,30 +211,43 @@
<default key="_controller">Thelia\Controller\Admin\AttributeController::createAction</default>
</route>
<route id="admin.configuration.attributes.create" path="/admin/configuration/attributes/create-value">
<default key="_controller">Thelia\Controller\Admin\AttributeController::createValueAction</default>
</route>
<route id="admin.configuration.attributes.update" path="/admin/configuration/attributes/update">
<default key="_controller">Thelia\Controller\Admin\AttributeController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\AttributeController::updateAction</default>
</route>
<route id="admin.configuration.attributes.save" path="/admin/configuration/attributes/save">
<default key="_controller">Thelia\Controller\Admin\AttributeController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\AttributeController::processUpdateAction</default>
</route>
<route id="admin.configuration.attributes.delete" path="/admin/configuration/attributes/delete">
<default key="_controller">Thelia\Controller\Admin\AttributeController::deleteAction</default>
</route>
<route id="admin.configuration.attributes.delete" path="/admin/configuration/attributes/delete-value">
<default key="_controller">Thelia\Controller\Admin\AttributeController::deleteValueAction</default>
</route>
<route id="admin.configuration.attributes.update-position" path="/admin/configuration/attributes/update-position">
<default key="_controller">Thelia\Controller\Admin\AttributeController::updatePositionAction</default>
</route>
<route id="admin.configuration.attributes-av.create" path="/admin/configuration/attributes-av/create">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::createAction</default>
</route>
<route id="admin.configuration.attributes-av.update" path="/admin/configuration/attributes-av/update">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::updateAction</default>
</route>
<route id="admin.configuration.attributes-av.save" path="/admin/configuration/attributes-av/save">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::processUpdateAction</default>
</route>
<route id="admin.configuration.attributes-av.delete" path="/admin/configuration/attributes-av/delete">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::deleteAction</default>
</route>
<route id="admin.configuration.attributes-av.update-position" path="/admin/configuration/attributes-av/update-position">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::updatePositionAction</default>
</route>
<!-- end attribute and feature routes management -->
<!-- The default route, to display a template -->

View File

@@ -28,7 +28,7 @@ use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ToggleVisibilityEvent;
/**
* Manages currencies sent by mail
* An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object.
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
@@ -53,6 +53,23 @@ abstract class AbstractCrudController extends BaseAdminController
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 $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"
*
* @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE
* @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE
* @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
*/
public function __construct(
$objectName,
@@ -187,15 +204,14 @@ abstract class AbstractCrudController extends BaseAdminController
}
/**
* Render the object list, ensuring the sort order is set.
*
* @return Symfony\Component\HttpFoundation\Response the response
* Return the current list order identifier, updating it in the same time.
*/
protected function renderList()
{
protected function getCurrentListOrder($update_session = true) {
$order = null;
if ($this->defaultListOrder != null) {
if ($this->defaultListOrder) {
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $this->objectName);
// Find the current order
@@ -204,11 +220,20 @@ abstract class AbstractCrudController extends BaseAdminController
$this->getSession()->get($orderSessionIdentifier, $this->defaultListOrder)
);
// Store the current sort order in session
$this->getSession()->set($orderSessionIdentifier, $order);
if ($update_session) $this->getSession()->set($orderSessionIdentifier, $order);
}
return $this->renderListTemplate($order);
return $order;
}
/**
* Render the object list, ensuring the sort order is set.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
protected function renderList()
{
return $this->renderListTemplate($this->getCurrentListOrder());
}
/**
@@ -286,7 +311,7 @@ abstract class AbstractCrudController extends BaseAdminController
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function changeAction()
public function updateAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
@@ -312,7 +337,7 @@ abstract class AbstractCrudController extends BaseAdminController
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function saveChangeAction()
public function processUpdateAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;

View File

@@ -122,7 +122,7 @@ class AttributeController extends AbstractCrudController
);
// Setup the object form
$changeForm = new AttributeModificationForm($this->getRequest(), "form", $data);
return new AttributeModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event) {
@@ -136,7 +136,7 @@ class AttributeController extends AbstractCrudController
}
protected function getObjectLabel($object) {
return $object->getName();
return $object->getTitle();
}
protected function getObjectId($object) {

View File

@@ -23,7 +23,7 @@
namespace Thelia\Core\Event;
class AttributeValueCreateEvent extends AttributeValueEvent
class AttributeAvCreateEvent extends AttributeAvEvent
{
protected $title;
protected $locale;

View File

@@ -23,23 +23,23 @@
namespace Thelia\Core\Event;
class AttributeValueDeleteEvent extends AttributeValueEvent
class AttributeAvDeleteEvent extends AttributeAvEvent
{
protected $attributeValue_id;
protected $attributeAv_id;
public function __construct($attributeValue_id)
public function __construct($attributeAv_id)
{
$this->setAttributeValueId($attributeValue_id);
$this->setAttributeAvId($attributeAv_id);
}
public function getAttributeValueId()
public function getAttributeAvId()
{
return $this->attributeValue_id;
return $this->attributeAv_id;
}
public function setAttributeValueId($attributeValue_id)
public function setAttributeAvId($attributeAv_id)
{
$this->attributeValue_id = $attributeValue_id;
$this->attributeAv_id = $attributeAv_id;
return $this;
}

View File

@@ -24,28 +24,28 @@
namespace Thelia\Core\Event;
use Thelia\Model\AttributeAv;
class AttributeValueEvent extends ActionEvent
class AttributeAvEvent extends ActionEvent
{
protected $attributeValue = null;
protected $attributeAv = null;
public function __construct(AttributeAv $attributeValue = null)
public function __construct(AttributeAv $attributeAv = null)
{
$this->attributeValue = $attributeValue;
$this->attributeAv = $attributeAv;
}
public function hasAttributeValue()
public function hasAttributeAv()
{
return ! is_null($this->attributeValue);
return ! is_null($this->attributeAv);
}
public function getAttributeValue()
public function getAttributeAv()
{
return $this->attributeValue;
return $this->attributeAv;
}
public function setAttributeValue($attributeValue)
public function setAttributeAv($attributeAv)
{
$this->attributeValue = $attributeValue;
$this->attributeAv = $attributeAv;
return $this;
}

View File

@@ -23,27 +23,27 @@
namespace Thelia\Core\Event;
class AttributeValueUpdateEvent extends AttributeValueCreateEvent
class AttributeAvUpdateEvent extends AttributeAvCreateEvent
{
protected $attributeValue_id;
protected $attributeAv_id;
protected $description;
protected $chapo;
protected $postscriptum;
public function __construct($attributeValue_id)
public function __construct($attributeAv_id)
{
$this->setAttributeValueId($attributeValue_id);
$this->setAttributeAvId($attributeAv_id);
}
public function getAttributeValueId()
public function getAttributeAvId()
{
return $this->attributeValue_id;
return $this->attributeAv_id;
}
public function setAttributeValueId($attributeValue_id)
public function setAttributeAvId($attributeAv_id)
{
$this->attributeValue_id = $attributeValue_id;
$this->attributeAv_id = $attributeAv_id;
return $this;
}

View File

@@ -365,17 +365,17 @@ final class TheliaEvents
// -- Attributes values management ----------------------------------------
const ATTRIBUTE_VALUE_CREATE = "action.createAttributeValue";
const ATTRIBUTE_VALUE_UPDATE = "action.updateAttributeValue";
const ATTRIBUTE_VALUE_DELETE = "action.deleteAttributeValue";
const ATTRIBUTE_VALUE_UPDATE_POSITION = "action.updateAttributeValuePosition";
const ATTRIBUTE_AV_CREATE = "action.createAttributeAv";
const ATTRIBUTE_AV_UPDATE = "action.updateAttributeAv";
const ATTRIBUTE_AV_DELETE = "action.deleteAttributeAv";
const ATTRIBUTE_AV_UPDATE_POSITION = "action.updateAttributeAvPosition";
const BEFORE_CREATEATTRIBUTE_VALUE = "action.before_createAttributeValue";
const AFTER_CREATEATTRIBUTE_VALUE = "action.after_createAttributeValue";
const BEFORE_CREATEATTRIBUTE_AV = "action.before_createAttributeAv";
const AFTER_CREATEATTRIBUTE_AV = "action.after_createAttributeAv";
const BEFORE_UPDATEATTRIBUTE_VALUE = "action.before_updateAttributeValue";
const AFTER_UPDATEATTRIBUTE_VALUE = "action.after_updateAttributeValue";
const BEFORE_UPDATEATTRIBUTE_AV = "action.before_updateAttributeAv";
const AFTER_UPDATEATTRIBUTE_AV = "action.after_updateAttributeAv";
const BEFORE_DELETEATTRIBUTE_VALUE = "action.before_deleteAttributeValue";
const AFTER_DELETEATTRIBUTE_VALUE = "action.after_deleteAttributeValue";
const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv";
const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv";
}

View File

@@ -28,6 +28,8 @@
<div class="col-md-12">
<div class="form-container">
{form name="thelia.admin.attribute.modification"}
<form method="POST" action="{url path='/admin/configuration/attributes/save'}" {form_enctype form=$form} class="clearfix">
{include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/attributes'}"}
@@ -35,9 +37,6 @@
<p class="title title-without-tabs">{intl l='Attribute information'}</p>
{form name="thelia.admin.attribute.modification"}
<form method="POST" action="{url path='/admin/configuration/attributes/save'}" {form_enctype form=$form} class="clearfix">
{* Be sure to get the attribute ID, even if the form could not be validated *}
<input type="hidden" name="attribute_id" value="{$attribute_id}" />
@@ -54,10 +53,6 @@
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{include file="includes/standard-description-form-fields.html"}
</form>
{/form}
</div>
<div class="col-md-6">
@@ -76,7 +71,7 @@
</p>
<div class="alert alert-info">
{intl l="Enter here all possible attribute values. If you don't enter any value, you will be able to set a free value to this attribute on the product form."}
{intl l="Enter here all possible attribute values."}
</div>
<table class="table table-striped table-condensed table-left-aligned">
@@ -160,6 +155,8 @@
</tbody>
</table>
</div>
</form>
{/form}
</div>
</div>
</div>
@@ -235,7 +232,7 @@
dialog_ok_label = {intl l="Create this value"}
form_action = {url path='/admin/configuration/attributes/create-value'}
form_action = {url path='/admin/configuration/attributes-av'}
form_enctype = {form_enctype form=$form}
form_error_message = $form_error_message
}
@@ -254,7 +251,7 @@
dialog_title = {intl l="Delete attribute value"}
dialog_message = {intl l="Do you really want to delete this attribute value ?"}
form_action = {url path='/admin/configuration/attributes/delete-value'}
form_action = {url path='/admin/configuration/attributes-av/delete'}
form_content = {$smarty.capture.delete_dialog nofilter}
}