allow country update
This commit is contained in:
@@ -59,7 +59,19 @@ class Country extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
public function update(CountryUpdateEvent $event)
|
||||
{
|
||||
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
|
||||
$country
|
||||
->setIsocode($event->getIsocode())
|
||||
->setIsoalpha2($event->getIsoAlpha2())
|
||||
->setIsoalpha3($event->getIsoAlpha3())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setChapo($event->getChapo())
|
||||
->setDescription($event->getDescription())
|
||||
->save();
|
||||
|
||||
$event->setCountry($country);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(CountryDeleteEvent $event)
|
||||
|
||||
@@ -420,11 +420,16 @@
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.save" path="/admin/configuration/country/save/{country_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::processUpdateAction</default>
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.delete" path="/admin/configuration/countries/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.toggle-default" path="/admin/configuration/country/toggleDefault">
|
||||
<route id="admin.configuration.countries.toggle-default" path="/admin/configuration/country/toggleDefault">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::toggleDefaultAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ class BaseAdminController extends BaseController
|
||||
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
|
||||
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
|
||||
*/
|
||||
public function redirectToRoute($routeId, $urlParameters = array(), $routeParameters = array())
|
||||
public function redirectToRoute($routeId, array $urlParameters = array(), array $routeParameters = array())
|
||||
{
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, $routeParameters), $urlParameters));
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ class CountryController extends AbstractCrudController
|
||||
*/
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$event = new CountryUpdateEvent();
|
||||
$event = new CountryUpdateEvent($formData['id']);
|
||||
|
||||
return $this->hydrateEvent($event, $formData);
|
||||
}
|
||||
@@ -139,6 +139,8 @@ class CountryController extends AbstractCrudController
|
||||
$event
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setIsocode($formData['isocode'])
|
||||
->setIsoAlpha2($formData['isoalpha2'])
|
||||
->setIsoAlpha3($formData['isoalpha3'])
|
||||
@@ -236,7 +238,10 @@ class CountryController extends AbstractCrudController
|
||||
*/
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.countries.update', array(), $this->getRequest()->get('country_id', 0));
|
||||
$this->redirectToRoute('admin.configuration.countries.update', array(), array(
|
||||
"country_id" => $this->getRequest()->get('country_id', 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,5 +31,90 @@ namespace Thelia\Core\Event\Country;
|
||||
*/
|
||||
class CountryUpdateEvent extends CountryCreateEvent
|
||||
{
|
||||
protected $country_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
function __construct($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $country_id
|
||||
*/
|
||||
public function setCountryId($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -122,16 +122,6 @@ abstract class DocumentModification extends BaseForm
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,16 +130,6 @@ abstract class ImageModification extends BaseForm
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,11 +58,11 @@
|
||||
<input class="change-default-toggle" type="radio" name="by_default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{* <td>
|
||||
<div class="make-switch switch-small switch-radio" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input class="change-default" type="radio" name="" value="{$ID}" {if $IS_DEFAULT}selected="selected"{/if}/>
|
||||
</div>
|
||||
</td>
|
||||
</td> *}
|
||||
<td>{$ISOCODE}</td>
|
||||
<td>{$ISOALPHA3}</td>
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
<div class="col-md-12">
|
||||
|
||||
{form name="thelia.admin.country.modification"}
|
||||
<form method="POST" action="{url path='/admin/configuration/countries/save'}" {form_enctype form=$form} class="clearfix">
|
||||
|
||||
<form method="POST" action="{url path="/admin/configuration/country/save/{$ID}"}" {form_enctype form=$form} class="clearfix">
|
||||
{include file = "includes/inner-form-toolbar.html"}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{* Be sure to get the country ID, even if the form could not be validated *}
|
||||
@@ -40,8 +40,12 @@
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/countries'}" />
|
||||
{/form_field}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/country/update/{$ID}"}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
@@ -74,51 +78,26 @@
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Alpha code 3'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl l="Translations"}
|
||||
</div>
|
||||
|
||||
{loop type="lang" name="lang"}
|
||||
<div class="col-md-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">
|
||||
<img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}"> {$TITLE}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$TITLE}" title="{intl l="{$label}"}" placeholder="{intl l='Country title'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l=""}" placeholder="{intl l='Country short description'}"></textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Country description'}"></textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Country title'}">
|
||||
</div>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-default btn-primary" title="{intl l='Add a new country'}">
|
||||
{intl l="Save"}
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
</button>
|
||||
{/form_field}
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l=""}" placeholder="{intl l='Country short description'}">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Country description'}">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user