Aded feature_template and category_template position management

This commit is contained in:
franck
2013-09-21 11:46:09 +02:00
parent f6530f0bfc
commit e3644cd6cc
33 changed files with 728 additions and 124 deletions

View File

@@ -135,6 +135,47 @@ class Template extends BaseAction implements EventSubscriberInterface
}
}
/**
* Changes position, selecting absolute ou relative change.
*
* @param CategoryChangePositionEvent $event
*/
public function updateAttributePosition(UpdatePositionEvent $event)
{
$attributeTemplate = AttributeTemplateQuery::create()->findPk($event->getObjectId());
$this->updatePosition($attributeTemplate, $event);
}
/**
* Changes position, selecting absolute ou relative change.
*
* @param CategoryChangePositionEvent $event
*/
public function updateFeaturePosition(UpdatePositionEvent $event)
{
$featureTemplate = FeatureTemplateQuery::create()->findPk($event->getObjectId());
$this->updatePosition($featureTemplate, $event);
}
protected function updatePosition($object, UpdatePositionEvent $event)
{
if (null !== $object) {
$object->setDispatcher($this->getDispatcher());
$mode = $event->getMode();
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
$object->changeAbsolutePosition($event->getPosition());
else if ($mode == UpdatePositionEvent::POSITION_UP)
$object->movePositionUp();
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
$object->movePositionDown();
}
}
public function deleteAttribute(TemplateDeleteAttributeEvent $event) {
$attribute_template = AttributeTemplateQuery::create()
@@ -185,6 +226,9 @@ class Template extends BaseAction implements EventSubscriberInterface
TheliaEvents::TEMPLATE_ADD_FEATURE => array("addFeature", 128),
TheliaEvents::TEMPLATE_DELETE_FEATURE => array("deleteFeature", 128),
TheliaEvents::TEMPLATE_CHANGE_ATTRIBUTE_POSITION => array('updateAttributePosition', 128),
TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION => array('updateFeaturePosition', 128),
);
}
}