| Conditions | 5 |
| Paths | 3 |
| Total Lines | 28 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 14.1113 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 44 | public function beforeController(FilterControllerEvent $event) |
|
| 35 | { |
||
| 36 | 44 | $controller = $event->getController(); |
|
| 37 | |||
| 38 | /* |
||
| 39 | * $controller passed can be either a class or a Closure. |
||
| 40 | * This is not usual in Symfony but it may happen. |
||
| 41 | * If it is a class, it comes in array format |
||
| 42 | * Do not process on test environment |
||
| 43 | */ |
||
| 44 | 44 | if (!is_array($controller) || $this->environment === Environment::TEST) { |
|
| 45 | 44 | return; |
|
| 46 | } |
||
| 47 | |||
| 48 | $token = $this->tokenStorage->getToken(); |
||
| 49 | /** @var User|null $user */ |
||
| 50 | $user = $token instanceof TokenInterface ? $token->getUser() : null; |
||
| 51 | $request = $event->getRequest(); |
||
| 52 | |||
| 53 | $message = sprintf( |
||
| 54 | '[%s] %s %s', |
||
| 55 | $user instanceof User ? $user->getLogin() : $request->getClientIp(), |
||
| 56 | $request->getMethod(), |
||
| 57 | $request->getPathInfo() |
||
| 58 | ); |
||
| 59 | |||
| 60 | $this->logger->addInfo($message); |
||
| 61 | } |
||
| 62 | } |
||
| 63 |