Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View vjandrea's full-sized avatar

Andrea Bergamasco vjandrea

View GitHub Profile
@vjandrea
vjandrea / AccessChecker.php
Last active July 29, 2021 12:04 — forked from leotiger/allowed_roles_for_route.md
Symfony 4: Check if a route is accessible to a User based on their roles
<?php
/**
* @Author Andrea Bergamasco <andrea@bergamasco.me>
* Inspired by @leotiger: https://gist.github.com/leotiger/ca496d1b16c30afea060904bd5e78714
*
* Usage:
* $token = $this->security->getToken();
* $this->accessChecker->userTokenCanAccessRoute($token, 'admin.index');
*/