Skip to content

Commit

Permalink
Use flashbag from session
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny van Wijk committed Apr 6, 2020
1 parent 87dac63 commit ac524c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php
Expand Up @@ -18,6 +18,7 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

/**
* Class NodeTranslationListener
Expand Down Expand Up @@ -46,22 +47,29 @@ class NodeTranslationListener
/**
* NodeTranslationListener constructor.
*
* @param FlashBagInterface $flashBag
* @param LoggerInterface $logger
* @param SlugifierInterface $slugifier
* @param RequestStack $requestStack
* @param DomainConfigurationInterface $domainConfiguration
* @param PagesConfiguration $pagesConfiguration
* @param SessionInterface|FlashBagInterface $session
* @param LoggerInterface $logger
* @param SlugifierInterface $slugifier
* @param RequestStack $requestStack
* @param DomainConfigurationInterface $domainConfiguration
* @param PagesConfiguration $pagesConfiguration
*/
public function __construct(
FlashBagInterface $flashBag,
/* SessionInterface */ $flashBag,
LoggerInterface $logger,
SlugifierInterface $slugifier,
RequestStack $requestStack,
DomainConfigurationInterface $domainConfiguration,
PagesConfiguration $pagesConfiguration
) {
$this->flashBag = $flashBag;

if ($flashBag instanceof FlashBagInterface) {
@trigger_error('Passing the "@session.flash_bag" service as first argument is deprecated since KunstmaanNodeBundle 5.6 and will be replaced by the session in KunstmaanNodeBundle 6.0. Inject the "@session" service instead.', E_USER_DEPRECATED);
} elseif ($flashBag instanceof SessionInterface) {
$this->flashBag = $flashBag->getFlashBag();
}

$this->logger = $logger;
$this->slugifier = $slugifier;
$this->requestStack = $requestStack;
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/NodeBundle/Resources/config/services.yml
Expand Up @@ -16,7 +16,7 @@ services:
kunstmaan_node.nodetranslation.listener:
class: Kunstmaan\NodeBundle\EventListener\NodeTranslationListener
arguments:
- '@session.flash_bag'
- '@session'
- '@kunstmaan_admin.logger'
- '@kunstmaan_utilities.slugifier'
- '@request_stack'
Expand Down

0 comments on commit ac524c4

Please sign in to comment.