|
@@ -156,7 +156,7 @@ class CRUDController extends Controller
|
|
|
// set the theme for the current Admin Form
|
|
|
$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
|
|
|
|
|
|
- return $this->render($this->admin->getListTemplate(), array(
|
|
|
+ return $this->render($this->admin->getTemplate('edit'), array(
|
|
|
'action' => 'list',
|
|
|
'form' => $formView,
|
|
|
'datagrid' => $datagrid
|
|
@@ -220,7 +220,7 @@ class CRUDController extends Controller
|
|
|
return new RedirectResponse($this->admin->generateUrl('list'));
|
|
|
}
|
|
|
|
|
|
- return $this->render('SonataAdminBundle:CRUD:delete.html.twig', array(
|
|
|
+ return $this->render($this->admin->getTemplate('delete'), array(
|
|
|
'object' => $object,
|
|
|
'action' => 'delete'
|
|
|
));
|
|
@@ -239,7 +239,7 @@ class CRUDController extends Controller
|
|
|
{
|
|
|
// the key used to lookup the template
|
|
|
$templateKey = 'edit';
|
|
|
-
|
|
|
+
|
|
|
$id = $this->get('request')->get($this->admin->getIdParameter());
|
|
|
|
|
|
$object = $this->admin->getObject($id);
|
|
@@ -259,9 +259,9 @@ class CRUDController extends Controller
|
|
|
|
|
|
if ($this->get('request')->getMethod() == 'POST') {
|
|
|
$form->bindRequest($this->get('request'));
|
|
|
-
|
|
|
- $isFormValid = $form->isValid();
|
|
|
-
|
|
|
+
|
|
|
+ $isFormValid = $form->isValid();
|
|
|
+
|
|
|
// persist if the form was valid and if in preview mode the preview was approved
|
|
|
if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
|
|
|
$this->admin->update($object);
|
|
@@ -277,7 +277,7 @@ class CRUDController extends Controller
|
|
|
// redirect to edit mode
|
|
|
return $this->redirectTo($object);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// show an error message if the form failed validation
|
|
|
if (!$isFormValid) {
|
|
|
$this->get('session')->setFlash('sonata_flash_error', 'flash_edit_error');
|
|
@@ -427,7 +427,7 @@ class CRUDController extends Controller
|
|
|
{
|
|
|
// the key used to lookup the template
|
|
|
$templateKey = 'edit';
|
|
|
-
|
|
|
+
|
|
|
if (false === $this->admin->isGranted('CREATE')) {
|
|
|
throw new AccessDeniedException();
|
|
|
}
|
|
@@ -441,9 +441,9 @@ class CRUDController extends Controller
|
|
|
|
|
|
if ($this->get('request')->getMethod() == 'POST') {
|
|
|
$form->bindRequest($this->get('request'));
|
|
|
-
|
|
|
- $isFormValid = $form->isValid();
|
|
|
-
|
|
|
+
|
|
|
+ $isFormValid = $form->isValid();
|
|
|
+
|
|
|
// persist if the form was valid and if in preview mode the preview was approved
|
|
|
if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
|
|
|
$this->admin->create($object);
|
|
@@ -459,7 +459,7 @@ class CRUDController extends Controller
|
|
|
// redirect to edit mode
|
|
|
return $this->redirectTo($object);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// show an error message if the form failed validation
|
|
|
if (!$isFormValid) {
|
|
|
$this->get('session')->setFlash('sonata_flash_error', 'flash_create_error');
|
|
@@ -480,10 +480,10 @@ class CRUDController extends Controller
|
|
|
'object' => $object,
|
|
|
));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Returns true if the preview is requested to be shown
|
|
|
- *
|
|
|
+ *
|
|
|
* @return boolean
|
|
|
*/
|
|
|
protected function isPreviewRequested()
|
|
@@ -493,20 +493,20 @@ class CRUDController extends Controller
|
|
|
|
|
|
/**
|
|
|
* Returns true if the preview has been approved
|
|
|
- *
|
|
|
+ *
|
|
|
* @return boolean
|
|
|
*/
|
|
|
protected function isPreviewApproved()
|
|
|
{
|
|
|
return ($this->get('request')->get('btn_preview_approve') !== null);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Returns true if the request is in the preview workflow
|
|
|
- *
|
|
|
+ *
|
|
|
* That means either a preview is requested or the preview has already been shown
|
|
|
* and it got approved/declined.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return boolean
|
|
|
*/
|
|
|
protected function isInPreviewMode()
|
|
@@ -519,7 +519,7 @@ class CRUDController extends Controller
|
|
|
|
|
|
/**
|
|
|
* Returns true if the preview has been declined
|
|
|
- *
|
|
|
+ *
|
|
|
* @return boolean
|
|
|
*/
|
|
|
protected function isPreviewDeclined()
|
|
@@ -548,7 +548,7 @@ class CRUDController extends Controller
|
|
|
|
|
|
$this->admin->setSubject($object);
|
|
|
|
|
|
- return $this->render($this->admin->getShowTemplate(), array(
|
|
|
+ return $this->render($this->admin->getTemplate('show'), array(
|
|
|
'action' => 'show',
|
|
|
'object' => $object,
|
|
|
'elements' => $this->admin->getShow(),
|
|
@@ -630,7 +630,7 @@ class CRUDController extends Controller
|
|
|
|
|
|
$this->admin->setSubject($object);
|
|
|
|
|
|
- return $this->render($this->admin->getShowTemplate(), array(
|
|
|
+ return $this->render($this->admin->getTemplate('show'), array(
|
|
|
'action' => 'show',
|
|
|
'object' => $object,
|
|
|
'elements' => $this->admin->getShow(),
|