Skip to content

Commit

Permalink
Merge pull request #12 from lingoda/05-fix-deprecated-flashbag-session
Browse files Browse the repository at this point in the history
Fix deprecated flashbag
  • Loading branch information
jorisdugue committed Aug 31, 2020
2 parents 46fa2d7 + 8698f38 commit 43e0b88
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions Core/H5PSymfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use GuzzleHttp\Client;
use H5PPermission;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Router;
use Symfony\Component\Routing\RouterInterface;
Expand All @@ -42,9 +42,9 @@ class H5PSymfony implements \H5PFrameworkInterface
*/
private $manager;
/**
* @var FlashBagInterface
* @var Session
*/
private $flashBag;
private $session;
/**
* @var AuthorizationCheckerInterface
*/
Expand Down Expand Up @@ -72,25 +72,25 @@ class H5PSymfony implements \H5PFrameworkInterface
* @param EditorStorage $editorStorage
* @param TokenStorageInterface $tokenStorage
* @param EntityManagerInterface $manager
* @param FlashBagInterface $flashBag
* @param Session $session
* @param AuthorizationCheckerInterface $authorizationChecker
* @param EventDispatcherInterface $eventDispatcher
* @param RouterInterface $router
*/
public function __construct(H5POptions $options,
EditorStorage $editorStorage,
TokenStorageInterface $tokenStorage,
EntityManagerInterface $manager,
FlashBagInterface $flashBag,
AuthorizationCheckerInterface $authorizationChecker,
EventDispatcherInterface $eventDispatcher,
RouterInterface $router)
EditorStorage $editorStorage,
TokenStorageInterface $tokenStorage,
EntityManagerInterface $manager,
Session $session,
AuthorizationCheckerInterface $authorizationChecker,
EventDispatcherInterface $eventDispatcher,
RouterInterface $router)
{
$this->options = $options;
$this->editorStorage = $editorStorage;
$this->tokenStorage = $tokenStorage;
$this->manager = $manager;
$this->flashBag = $flashBag;
$this->session = $session;
$this->authorizationChecker = $authorizationChecker;
$this->eventDispatcher = $eventDispatcher;
$this->router = $router;
Expand Down Expand Up @@ -192,7 +192,7 @@ public function setLibraryTutorialUrl($machineName, $tutorialUrl)
*/
public function setErrorMessage($message, $code = NULL)
{
$this->flashBag->add("error", "[$code]: $message");
$this->session->getFlashBag()->add("error", "[$code]: $message");
}

/**
Expand All @@ -201,7 +201,7 @@ public function setErrorMessage($message, $code = NULL)
*/
public function setInfoMessage($message)
{
$this->flashBag->add("info", "$message");
$this->session->getFlashBag()->add("info", "$message");
}

/**
Expand All @@ -211,10 +211,10 @@ public function setInfoMessage($message)
*/
public function getMessages($type)
{
if (!$this->flashBag->has($type)) {
if (!$this->session->getFlashBag()->has($type)) {
return NULL;
}
$messages = $this->flashBag->get($type);
$messages = $this->session->getFlashBag()->get($type);
return $messages;
}

Expand Down Expand Up @@ -857,7 +857,7 @@ public function getLibraryStats($type)
$count = [];
/**
* @var Counters $results
*/
*/
$results = $this->manager->getRepository('StuditH5PBundle:Counters')->findBy(['type' => $type]);
// Extract results
foreach ($results as $library) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:

studit_h5p.interface:
class: Studit\H5PBundle\Core\H5PSymfony
arguments: ['@studit_h5p.options', '@studit_h5p.editor_storage','@security.token_storage', '@doctrine.orm.entity_manager', '@session.flash_bag', '@security.authorization_checker', '@event_dispatcher', '@router.default']
arguments: ['@studit_h5p.options', '@studit_h5p.editor_storage','@security.token_storage', '@doctrine.orm.entity_manager', '@session', '@security.authorization_checker', '@event_dispatcher', '@router.default']
Studit\H5PBundle\Core\H5PSymfony: '@studit_h5p.interface'

studit_h5p.core:
Expand Down

0 comments on commit 43e0b88

Please sign in to comment.