Pass the object id to the request
This commit is contained in:
@@ -160,11 +160,18 @@ abstract class AbstractSeoCrudController extends AbstractCrudController
|
|||||||
public function processUpdateSeoAction()
|
public function processUpdateSeoAction()
|
||||||
{
|
{
|
||||||
// Check current user authorization
|
// Check current user authorization
|
||||||
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response;
|
if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE))
|
||||||
|
return $response;
|
||||||
|
|
||||||
// Create the form from the request
|
// Error (Default: false)
|
||||||
|
$error_msg = false;
|
||||||
|
|
||||||
|
// Create the Form from the request
|
||||||
$updateSeoForm = $this->getUpdateSeoForm($this->getRequest());
|
$updateSeoForm = $this->getUpdateSeoForm($this->getRequest());
|
||||||
|
|
||||||
|
// Pass the object id to the request
|
||||||
|
$this->getRequest()->attributes->set($this->objectName . '_id', $this->getRequest()->get('current_id'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Check the form against constraints violations
|
// Check the form against constraints violations
|
||||||
@@ -173,32 +180,41 @@ abstract class AbstractSeoCrudController extends AbstractCrudController
|
|||||||
// Get the form field values
|
// Get the form field values
|
||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
|
|
||||||
|
// Create a new event object with the modified fields
|
||||||
$updateSeoEvent = $this->getUpdateSeoEvent($data);
|
$updateSeoEvent = $this->getUpdateSeoEvent($data);
|
||||||
|
|
||||||
|
// Dispatch Update SEO Event
|
||||||
$this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent);
|
$this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent);
|
||||||
|
|
||||||
|
// Execute additional Action
|
||||||
|
$response = $this->performAdditionalUpdateSeoAction($updateSeoEvent);
|
||||||
|
|
||||||
|
if ($response == null) {
|
||||||
|
// If we have to stay on the same page, do not redirect to the successUrl,
|
||||||
|
// just redirect to the edit page again.
|
||||||
|
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||||
|
$this->redirectToEditionTemplate($this->getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to the success URL
|
||||||
|
$this->redirect($updateSeoForm->getSuccessUrl());
|
||||||
|
} else {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
} catch (FormValidationException $ex) {
|
} catch (FormValidationException $ex) {
|
||||||
// Form cannot be validated
|
// Form cannot be validated
|
||||||
return $this->createStandardFormValidationErrorMessage($ex);
|
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||||
} catch (\Exception $ex) {
|
/*} catch (\Exception $ex) {
|
||||||
// Any error
|
// Any other error
|
||||||
return $this->errorPage($ex);
|
$error_msg = $ex->getMessage();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->performAdditionalUpdateSeoAction($updateSeoEvent);
|
$this->setupFormErrorContext(
|
||||||
|
$this->getTranslator()->trans("%obj SEO modification", array('%obj' => $this->objectName)),
|
||||||
if ($response == null) {
|
$error_msg,
|
||||||
// If we have to stay on the same page, do not redirect to the successUrl,
|
$updateSeoForm,
|
||||||
// just redirect to the edit page again.
|
$ex
|
||||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
);
|
||||||
$this->redirectToEditionTemplate($this->getRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirect to the success URL
|
|
||||||
$this->redirect($updateSeoForm->getSuccessUrl());
|
|
||||||
} else {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
// At this point, the form has errors, and should be redisplayed.
|
// At this point, the form has errors, and should be redisplayed.
|
||||||
return $this->renderEditionTemplate();
|
return $this->renderEditionTemplate();
|
||||||
|
|||||||
Reference in New Issue
Block a user