Building an ACL based on permission level I'm building a symfony project and at some point I've come up with a switch case to manage the acl rights. I would prefer using a dynamic access to the constant but havn't find a good solution. I've seen reflection but that doesn't seem to be the proper solution to me.

$mask = null;

switch ($participant-&gt;getRight()) {
    case 'VIEW':
        $mask = MaskBuilder::MASK_VIEW;
        break;
    case 'EDIT':
        $mask = MaskBuilder::MASK_EDIT;
        break;
    case 'OPERATOR':
        $mask = MaskBuilder::MASK_OPERATOR;
        break;
    default:
        break;
}
$this-&gt;aclManager-&gt;addObjectPermission($project, $mask, $user);


So, this switch is in a foreach, that gets the $user entity, then with the result of the list box from the view, I get the rights of the user which can be (for now) EDIT VIEW or OPERATOR. These right were chosen because they are directly related to the MaskBuilder masks. 

The thing is, if there is a refactor to be done, I will need to modify this switch AND the part where the form is defined. I would like to do something like

$mask = 'MASK_' . $participant-&gt;getRight();
$this-&gt;aclManager-&gt;addObjectPermissions($project, MaskBuilder::$mask, $user);


But havn't find a way to do it.

Is my switch a good way to do it ? Or is there a proper php way to do the same, that would reduce refactor cost?
I found the solution somewhere from the documentation.  I don't know why I had not seen that before.

Symfony2 provides an easier way of doing what I was looking for:

$builder = new MaskBuilder();
$mask = $builder-&gt;add($participant-&gt;getRight())-&gt;get();