Skip to content

Commit

Permalink
fix some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Sep 25, 2023
1 parent 4dbf8b3 commit 0d40ae8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
10 changes: 0 additions & 10 deletions src/Adapter/User/UserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ trait UserTrait
*/
protected ?string $plainPassword = null;

/**
* This method is deprecated since Symfony 5.3
*
* @deprecated
*/
public function getSalt(): ?string
{
return null;
}

public function getUserIdentifier(): string
{
$authIdentifier = \Pimcore::getContainer()?->getParameter('members.auth.identifier');
Expand Down
14 changes: 10 additions & 4 deletions src/EventListener/FlashListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use MembersBundle\MembersEvents;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Pimcore\Translation\Translator;
Expand Down Expand Up @@ -43,22 +44,27 @@ public function addSuccessFlash(Event $event, string $eventName): void
throw new \InvalidArgumentException('This event does not correspond to a known flash message.');
}

$this->getSession()->getFlashBag()->add('success', $this->trans(self::$successMessages[$eventName]));
$this->getFlashBag()?->add('success', $this->trans(self::$successMessages[$eventName]));
}

private function trans(string $message, array $params = []): string
{
return $this->translator->trans($message, $params);
}

private function getSession(): SessionInterface
private function getFlashBag(): ?FlashBagInterface
{
$request = $this->requestStack->getCurrentRequest();

if ($request === null) {
throw new \LogicException('Cannot get the session without an active request.');
}

return $request->getSession();
$session = $request->getSession();
if (!$session instanceof FlashBagAwareSessionInterface) {
return null;
}

return $session->getFlashBag();
}
}

0 comments on commit 0d40ae8

Please sign in to comment.