Using Symfony 4.4, I'd like to add on the fly to all my a route parameter if it's found in the on request. E.g. for the user Id:
PUT | DELETE | POST mywebsite.com/users/{userid}/some-action
I could add my users ids each time I log but it's kind of cumbersome.
So I created a service:
//src/
// |__Services/
// |___UserProcessor.php
use Monolog\Processor\ProcessorInterface;
use Symfony\Component\HttpFoundation\RequestStack;
// In my config.yaml this monolog.processor
final class UserProcessor implements ProcessorInterface
{
private RequestStack $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function __invoke(array $record): array
{
dd($this->requestStack->getMasterRequest()->attributes);
}
}
When I run my postman on POST /users/{userid}/some-action I get this output:
[
"media_type" => "application/json"
]
From my understanding, symfony route parameters request attributes are not built yet at the moment my processor runs.
What should I do to make my processor access the attribute userid?