allow to create a new area
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
namespace Thelia\Action;
|
namespace Thelia\Action;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
||||||
|
use Thelia\Core\Event\Area\AreaCreateEvent;
|
||||||
use Thelia\Core\Event\Area\AreaDeleteEvent;
|
use Thelia\Core\Event\Area\AreaDeleteEvent;
|
||||||
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
||||||
use Thelia\Core\Event\Area\AreaUpdatePostageEvent;
|
use Thelia\Core\Event\Area\AreaUpdatePostageEvent;
|
||||||
@@ -31,6 +32,7 @@ use Thelia\Core\Event\TheliaEvents;
|
|||||||
use Thelia\Model\AreaQuery;
|
use Thelia\Model\AreaQuery;
|
||||||
use Thelia\Model\CountryQuery;
|
use Thelia\Model\CountryQuery;
|
||||||
use Thelia\Action\BaseAction;
|
use Thelia\Action\BaseAction;
|
||||||
|
use Thelia\Model\Area as AreaModel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,6 +85,18 @@ class Area extends BaseAction implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function create(AreaCreateEvent $event)
|
||||||
|
{
|
||||||
|
$area = new AreaModel();
|
||||||
|
|
||||||
|
$area
|
||||||
|
->setDispatcher($this->getDispatcher())
|
||||||
|
->setName($event->getAreaName())
|
||||||
|
->save();
|
||||||
|
|
||||||
|
$event->setArea($area);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of event names this subscriber wants to listen to.
|
* Returns an array of event names this subscriber wants to listen to.
|
||||||
@@ -110,7 +124,8 @@ class Area extends BaseAction implements EventSubscriberInterface
|
|||||||
TheliaEvents::AREA_ADD_COUNTRY => array('addCountry', 128),
|
TheliaEvents::AREA_ADD_COUNTRY => array('addCountry', 128),
|
||||||
TheliaEvents::AREA_REMOVE_COUNTRY => array('removeCountry', 128),
|
TheliaEvents::AREA_REMOVE_COUNTRY => array('removeCountry', 128),
|
||||||
TheliaEvents::AREA_POSTAGE_UPDATE => array('updatePostage', 128),
|
TheliaEvents::AREA_POSTAGE_UPDATE => array('updatePostage', 128),
|
||||||
TheliaEvents::AREA_DELETE => array('delete', 128)
|
TheliaEvents::AREA_DELETE => array('delete', 128),
|
||||||
|
TheliaEvents::AREA_CREATE => array('create', 128)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -700,6 +700,10 @@
|
|||||||
<default key="_controller">Thelia\Controller\Admin\AreaController::deleteAction</default>
|
<default key="_controller">Thelia\Controller\Admin\AreaController::deleteAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.shipping-configuration.create" path="/admin/configuration/shipping_configuration/create">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\AreaController::createAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
<route id="admin.configuration.shipping-configuration.update.postage" path="/admin/configuration/shipping_configuration/update_postage/{area_id}">
|
<route id="admin.configuration.shipping-configuration.update.postage" path="/admin/configuration/shipping_configuration/update_postage/{area_id}">
|
||||||
<default key="_controller">Thelia\Controller\Admin\AreaController::updatePostageAction</default>
|
<default key="_controller">Thelia\Controller\Admin\AreaController::updatePostageAction</default>
|
||||||
<requirement key="area_id">\d+</requirement>
|
<requirement key="area_id">\d+</requirement>
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class AreaController extends AbstractCrudController
|
|||||||
|
|
||||||
private function hydrateEvent($event, $formData)
|
private function hydrateEvent($event, $formData)
|
||||||
{
|
{
|
||||||
$event->setName($formData['name']);
|
$event->setAreaName($formData['name']);
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class AreaCreateEvent extends AreaEvent
|
|||||||
/**
|
/**
|
||||||
* @param mixed $name
|
* @param mixed $name
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setAreaName($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ class AreaCreateEvent extends AreaEvent
|
|||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getAreaName()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,16 +75,23 @@
|
|||||||
|
|
||||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||||
{capture "creation_dialog"}
|
{capture "creation_dialog"}
|
||||||
|
{form name="thelia.admin.area.create"}
|
||||||
|
{form_hidden_fields form=$form}
|
||||||
|
|
||||||
|
{form_field form=$form field='success_url'}
|
||||||
|
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
|
||||||
|
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/shipping_configuration/update/_ID_'}" />
|
||||||
|
{/form_field}
|
||||||
|
{form_field form=$form field="name"}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="" class="control-label">{intl l="Name"} : </label>
|
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||||
<input type="text" id="" name="" class="form-control" title="{intl l="Name"}" placeholder="{intl l='Shipping configuration name'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="Name"}" placeholder="{intl l='Shipping configuration name'}">
|
||||||
</div>
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
|
|
||||||
{module_include location='shipping_configuration_create_form'}
|
{module_include location='shipping_configuration_create_form'}
|
||||||
|
{/form}
|
||||||
{/capture}
|
{/capture}
|
||||||
|
|
||||||
{include
|
{include
|
||||||
@@ -97,7 +104,7 @@
|
|||||||
dialog_ok_label = {intl l="Create this shipping configuration"}
|
dialog_ok_label = {intl l="Create this shipping configuration"}
|
||||||
dialog_cancel_label = {intl l="Cancel"}
|
dialog_cancel_label = {intl l="Cancel"}
|
||||||
|
|
||||||
form_action = {url path='/admin/configuration/configuration/shipping_configuration/create'}
|
form_action = {url path='/admin/configuration/shipping_configuration/create'}
|
||||||
form_enctype = ''
|
form_enctype = ''
|
||||||
form_error_message = $form_error_message
|
form_error_message = $form_error_message
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user