Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's how I solved it (this has become easier in Symfony 2.3 after I submitted a PR):</p> <p>Extend the existing MaskBuilder with your own masks:</p> <pre><code>namespace Acme\DemoBundle\Security\Acl\Permission; use Symfony\Component\Security\Acl\Permission\MaskBuilder as BaseMaskBuilder; class MaskBuilder extends BaseMaskBuilder { const MASK_COPY = 256; // 1 &lt;&lt; 8 const MASK_REVIEW = 512; // 1 &lt;&lt; 9 const CODE_COPY = 'X'; const CODE_REVIEW = 'R'; } </code></pre> <p>Extend the existing PermissionMap (you used to have to completely override it, as everything was set to private). </p> <pre><code>namespace Acme\DemoBundle\Security\Acl\Permission; use Symfony\Component\Security\Acl\Permission\BasicPermissionMap; class PermissionMap extends BasicPermissionMap { const PERMISSION_COPY = 'COPY'; const PERMISSION_REVIEW = 'REVIEW'; public function __construct() { parent::__construct(); // This basically says "If you have VIEW, REVIEW, EDIT..., OWNER, // you have VIEW". $this-&gt;map[self::PERMISSION_VIEW] = array( MaskBuilder::MASK_VIEW, MaskBuilder::MASK_REVIEW, MaskBuilder::MASK_EDIT, MaskBuilder::MASK_COPY, MaskBuilder::MASK_OPERATOR, MaskBuilder::MASK_MASTER, MaskBuilder::MASK_OWNER, ); $this-&gt;map[self::PERMISSION_COPY] = array( MaskBuilder::MASK_COPY, MaskBuilder::MASK_OPERATOR, MaskBuilder::MASK_MASTER, MaskBuilder::MASK_OWNER, ); $this-&gt;map[self::PERMISSION_REVIEW] = array( MaskBuilder::MASK_REVIEW, MaskBuilder::MASK_OPERATOR, MaskBuilder::MASK_MASTER, MaskBuilder::MASK_OWNER, ); } } </code></pre> <p>Don't ask me why you have to include the same permission.</p> <p>Lastly, you need to tell Symfony to use your PermissionMap in <code>config.yml</code>:</p> <pre><code>parameters: security.acl.permission.map.class: Acme\DemoBundle\Security\Acl\Permission\PermissionMap </code></pre> <p>That did it for me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload