adding useful snippets

This commit is contained in:
2017-03-13 00:40:16 +01:00
parent 8ced86c60e
commit 5ccafcb73f
3 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
Useful snippets
###############
Security
********
Get the circles a user can reach
================================
.. code-block:: php
use Symfony\Component\Security\Core\Role\Role;
$authorizationHelper = $this->get('chill.main.security.authorization.helper');
$circles = $authorizationHelper
->getReachableCircles(
$this->getUser(), # from a controller
new Role('CHILL_ROLE'),
$center
);
Controller
**********
Secured controller for person
=============================
.. literalinclude:: useful-snippets/controller-secured-for-person.php
:language: php