Skip to content

Commit

Permalink
Remove @session service
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup authored Jun 4, 2024
1 parent 0669608 commit c8d6f87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Event/Listener/FormSuccessListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;

class FormSuccessListener implements EventSubscriberInterface
Expand All @@ -32,9 +33,9 @@ class FormSuccessListener implements EventSubscriberInterface
/**
* @param Session<string> $session
*/
public function __construct(Session $session) // Don't type-hint against SessionInterface, as the interface doesn't have the getFlashBag method
public function __construct(RequestStack $requestStack)
{
$this->session = $session;
$this->session = $requestStack->getCurrentRequest()->getSession();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:

solidworx.form_handler.success:
class: SolidWorx\FormHandler\Event\Listener\FormSuccessListener
arguments: ['@session']
arguments: ['@request_stack']
tags:
- { name: 'kernel.event_subscriber' }

Expand Down

0 comments on commit c8d6f87

Please sign in to comment.