-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
148 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...p/Bundle/StorageListBundle/Core/EventListener/SessionStoreStorageListLogoutSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* CoreShop | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - CoreShop Commercial License (CCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org) | ||
* @license https://www.coreshop.org/license GPLv3 and CCL | ||
* | ||
*/ | ||
|
||
namespace CoreShop\Bundle\StorageListBundle\Core\EventListener; | ||
|
||
use CoreShop\Component\StorageList\Context\StorageListContextInterface; | ||
use CoreShop\Component\StorageList\Context\StorageListNotFoundException; | ||
use CoreShop\Component\Store\Model\StoreAwareInterface; | ||
use Symfony\Component\Security\Http\Event\LogoutEvent; | ||
|
||
final class SessionStoreStorageListLogoutSubscriber | ||
{ | ||
public function __construct( | ||
private StorageListContextInterface $context, | ||
private string $sessionKeyName, | ||
) { | ||
} | ||
|
||
public function onLogoutSuccess(LogoutEvent $event): void | ||
{ | ||
$request = $event->getRequest(); | ||
|
||
if (!$request->hasSession()) { | ||
return; | ||
} | ||
|
||
if ($request->attributes->get('_stateless', false)) { | ||
return; | ||
} | ||
|
||
$request = $event->getRequest(); | ||
|
||
try { | ||
$storageList = $this->context->getStorageList(); | ||
} catch (StorageListNotFoundException) { | ||
return; | ||
} | ||
|
||
if (!$storageList instanceof StoreAwareInterface) { | ||
return; | ||
} | ||
|
||
if (null !== $storageList->getStore()) { | ||
$session = $request->getSession(); | ||
|
||
$session->remove(sprintf('%s.%s', $this->sessionKeyName, $storageList->getStore()->getId())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters