Skip to content

Commit

Permalink
chore: ensure test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mussbach committed Sep 11, 2024
1 parent 888274f commit caacfbd
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@
use DemosEurope\DemosplanAddon\Contracts\PermissionsInterface;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\KernelInterface;

#[AsEventListener(event: 'kernel.controller', priority: 5)]
class SetHttpTestPermissionsListener
{
public const X_DPLAN_TEST_PERMISSIONS = 'x-dplan-test-permissions';

public function __construct(
private readonly KernelInterface $kernel,
private readonly PermissionsInterface $permissions,
) {
}

public function onKernelController(ControllerEvent $controllerEvent): void
{
if ($this->kernel->getEnvironment() !== 'test') {
return;
}

$request = $controllerEvent->getRequest();
if ($request->server->has(self::X_DPLAN_TEST_PERMISSIONS)) {
$permissions = $request->server->get(self::X_DPLAN_TEST_PERMISSIONS);
Expand Down

0 comments on commit caacfbd

Please sign in to comment.