Last active
August 29, 2015 14:02
-
-
Save zyphlar/036ce72a0a868b98490d to your computer and use it in GitHub Desktop.
Prototype of a Symfony2 PHP securitycontext filter helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SomeController { | |
private function filterSecurityContext($action, $items){ | |
$user = $this->get('security.context')->getToken()->getUser(); | |
$results = array(); | |
foreach($items as $item){ | |
if($this->get('security.context')->isGranted($action, $item)){ | |
$results[] = $item; | |
} | |
} | |
return $results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment