Skip to content

Commit ac43f81

Browse files
Merge branch '4.4'
* 4.4: sync phpunit script with master [HttpFoundation] allow additinal characters in not raw cookies [Console] Deprecate abbreviating hidden command names using Application->find() Do not include hidden commands in suggested alternatives [Messenger] Improve error message when routing to an invalid transport (closes #31613) [DependencyInjection] Fix wrong exception when service is synthetic [Security] add "anonymous: lazy" mode to firewalls
2 parents d83ec43 + 6f78ca3 commit ac43f81

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Authentication/Token/Storage/TokenStorage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@
2525
class TokenStorage implements TokenStorageInterface, ResetInterface
2626
{
2727
private $token;
28+
private $initializer;
2829

2930
/**
3031
* {@inheritdoc}
3132
*/
3233
public function getToken()
3334
{
35+
if ($initializer = $this->initializer) {
36+
$this->initializer = null;
37+
$initializer();
38+
}
39+
3440
return $this->token;
3541
}
3642

@@ -39,9 +45,15 @@ public function getToken()
3945
*/
4046
public function setToken(TokenInterface $token = null)
4147
{
48+
$this->initializer = null;
4249
$this->token = $token;
4350
}
4451

52+
public function setInitializer(?callable $initializer): void
53+
{
54+
$this->initializer = $initializer;
55+
}
56+
4557
public function reset()
4658
{
4759
$this->setToken(null);

Exception/LazyResponseException.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Core\Exception;
13+
14+
use Symfony\Component\HttpFoundation\Response;
15+
16+
/**
17+
* A signaling exception that wraps a lazily computed response.
18+
*
19+
* @author Nicolas Grekas <[email protected]>
20+
*/
21+
class LazyResponseException extends \Exception implements ExceptionInterface
22+
{
23+
private $response;
24+
25+
public function __construct(Response $response)
26+
{
27+
$this->response = $response;
28+
}
29+
30+
public function getResponse(): Response
31+
{
32+
return $this->response;
33+
}
34+
}

0 commit comments

Comments
 (0)