Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Redirect handling, breaking changes for sf < 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonbaeten committed Jul 25, 2016
1 parent f1977db commit 6a2e220
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"symfony/symfony": "~2.3|~3.0",
"symfony/symfony": "~2.6|~3.0",
"doctrine/doctrine-bundle": "~1.6",
"doctrine/orm": "~2.5",
"knplabs/knp-paginator-bundle": "~2.5"
Expand Down
15 changes: 11 additions & 4 deletions src/Bravesheep/CrudifyBundle/Controller/AbstractCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

/**
* Class AbstractCrudController
* @package Bravesheep\CrudifyBundle\Controller
*/
abstract class AbstractCrudController extends Controller implements CrudControllerInterface
{
/**
* @param IndexDefinitionInterface $definition
* @return Query
*/
protected function createSelectQuery(IndexDefinitionInterface $definition)
Expand Down Expand Up @@ -104,9 +109,10 @@ public function getLink($action, DefinitionInterface $definition, $object = null

/**
* @param DefinitionInterface $definition
* @param object $object
* @param Request $request
* @param object $object
* @param Request $request
* @return Response
* @throws CrudifyException
*/
protected function determineSuccessResponse(DefinitionInterface $definition, $object, Request $request)
{
Expand All @@ -118,7 +124,7 @@ protected function determineSuccessResponse(DefinitionInterface $definition, $ob
return $this->redirect($this->getLink('edit', $definition, $object));
} elseif ($action === 'index') {
// redirect back to stored referer
$referer = $this->get('session')->remove('edit_referer');
$referer = $this->get('session')->remove('edit_referer_' . $definition->getName());
if ($referer) {
return $this->redirect($referer);
}
Expand All @@ -132,11 +138,12 @@ protected function determineSuccessResponse(DefinitionInterface $definition, $ob
/**
* @param string $what
* @param object $object
* @return void
* @throws AccessDeniedException
*/
protected function isGranted($what, $object = null)
{
if (!$this->get('security.context')->isGranted($what, $object)) {
if (!$this->get('security.authorization_checker')->isGranted($what, $object)) {
throw new AccessDeniedException("Not allowed to {$what} on object");
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Bravesheep/CrudifyBundle/Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public function editAction(DefinitionInterface $definition, Request $request, $i

// store referer to redirect back after save
if (!$this->get('session')->remove('ignore_referer')) {
$this->get('session')->set('edit_referer', $request->headers->get('referer'));
$this->get('session')->set(
'edit_referer_' . $definition->getName(),
$request->headers->get('referer')
);
}

$form = $this->createUpdateForm($definition, $object);
Expand Down

0 comments on commit 6a2e220

Please sign in to comment.