Skip to content

Instantly share code, notes, and snippets.

@wouterj
Created May 27, 2014 12:51
Show Gist options
  • Select an option

  • Save wouterj/f9b5a6175403c0b1a4b6 to your computer and use it in GitHub Desktop.

Select an option

Save wouterj/f9b5a6175403c0b1a4b6 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\HttpFoundation\Request;
// deze inject je
$router = ...; // router
$accessMap = ...; // security.access_map
$accessDecisionManager = ...; // security.access.decision_manager
$route = 'admin_homepage';
$url = $router->generate($route);
$request = Request::create($url);
list($attributes, $channel) = $accessMap->getPatterns($request);
if (null === $attributes) {
return;
}
if ($this->accessDecisionManager->decide($token, $attributes, $request)) {
// toon menu item
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment