I\'m making a form for user creation, and I want to give one or several roles to a user when I create him.
How do I get the list of roles defined in security.y
//FormType
use Symfony\Component\Yaml\Parser;
function getRolesNames(){
$pathToSecurity = /var/mydirectory/app/config/security.yml
$yaml = new Parser();
$rolesArray = $yaml->parse(file_get_contents($pathToSecurity ));
return $rolesArray['security']['role_hierarchy']['ROLE_USER'];
}
This is so far the best way i found to get or set what i want from config files.
Bon courage