mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-30 09:49:31 +00:00
adding useful snippets
This commit is contained in:
35
source/development/useful-snippets.rst
Normal file
35
source/development/useful-snippets.rst
Normal 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
|
||||
Reference in New Issue
Block a user