Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit 3ff41ef

Browse files
committed
Merge pull request #10 from mvrhov/sf3
Symfony 3.0 support. This will work with security component from symfony 2.6 up
2 parents 89665d6 + 0ec2bc8 commit 3ff41ef

File tree

4 files changed

+441
-7
lines changed

4 files changed

+441
-7
lines changed

KernelExceptionListener.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
77
use Symfony\Component\HttpFoundation\Response;
88
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
9-
use Symfony\Component\Security\Core\SecurityContext;
9+
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1010
use Tracy\Debugger;
1111

1212
class KernelExceptionListener
1313
{
1414
private $storeUsernameInServerVariable;
15-
private $securityContext;
15+
private $tokenStorage;
1616
/** @var array */
1717
private $ignoredExceptions;
1818

19-
public function __construct($storeUsernameInServerVariable, SecurityContext $securityContext, array $ignoredExceptions)
19+
public function __construct($storeUsernameInServerVariable, TokenStorageInterface $tokenStorage, array $ignoredExceptions)
2020
{
2121
$this->storeUsernameInServerVariable = $storeUsernameInServerVariable;
22-
$this->securityContext = $securityContext;
22+
$this->tokenStorage = $tokenStorage;
2323
$this->ignoredExceptions = $ignoredExceptions;
2424
}
2525

@@ -58,7 +58,7 @@ private function isIgnoredException(Exception $exception)
5858

5959
private function storeUsernameInServerVariable()
6060
{
61-
$token = $this->securityContext->getToken();
61+
$token = $this->tokenStorage->getToken();
6262

6363
if ($token) {
6464
$_SERVER['SYMFONY_USERNAME'] = $token->getUsername();

Resources/config/services.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<services>
88
<service id="kutny_tracy_kernel_exception_listener" class="Kutny\TracyBundle\KernelExceptionListener">
99
<argument>%kutny_tracy.store_username_in_server_variable%</argument>
10-
<argument type="service" id="security.context" />
10+
<argument type="service" id="security.token_storage" />
1111
<argument>%kutny_tracy.ignored_exceptions%</argument>
1212
<tag name="kernel.event_listener" event="kernel.exception" method="onKernelException"/>
1313
<tag name="kernel.event_listener" event="console.exception" method="onConsoleException"/>

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"require": {
1515
"php": ">=5.3.2",
1616
"tracy/tracy": "2.3.*",
17-
"symfony/security": "<3.0"
17+
"symfony/security": "~2.6|~3.0"
1818
},
1919
"autoload": {
2020
"psr-0": {

0 commit comments

Comments
 (0)