title: Symfony 2 ACL vs Voters
body: <p>I want to use isGranted('EDIT', $userObject) for allow edit given user data by all administrators and managers and that one user.</p>
  
  <p>Should I use ACL for control edit $userObject?
  I have written extra Voter which check if logged user and given object are the same or user is manager or admin.</p>
  
  <p>In acl I must add ACE for userObject for all administrators, managers and that one user.</p>
  
  <p>Wchich way is recommended?
  I am new in Symfony..</p>
  
  <p>below is voter's code:</p>
  
  <pre><code>function vote(TokenInterface $token, $object, array $attributes)
  {
      $intersect=array_intersect(array('EDIT','VIEW' ), $attributes);
      if (!empty($intersect))
      {
          //intersect is not empty, it seems to edit or view are in $attributes
          //voter grants privileges for [user-&gt;granted object]
          //manager-&gt;every customer, child-manager
          //admin-&gt;every customer and manager
          if ($token-&gt;getUser()-&gt;isAdmin())
          {
              return VoterInterface::ACCESS_GRANTED;
          }
          elseif ($token-&gt;getUser()-&gt;isCustomer())
          {
              //voter not want to think about customer grants, because customer grants currently are held in ACL
              return VoterInterface::ACCESS_ABSTAIN;
          }
          /* @var $object \PSB\StoreBundle\Entity\Customer */
          if (is_a($object, '\PSB\StoreBundle\Entity\Customer'))
          {
  
              if ($token-&gt;getUser()-&gt;isManager())
              {
                  //managers also edit customers
                  return VoterInterface::ACCESS_GRANTED;
              }
          }
          elseif (is_a($object, '\PSB\StoreBundle\Entity\Manager'))
          {
              /* @var $object \PSB\StoreBundle\Entity\Manager */
              if ($token-&gt;getUser()-&gt;isManager())
              {
                  //manager can edit own children
                  if ($token-&gt;getUser() == $object-&gt;getParent())
                  {
                      return VoterInterface::ACCESS_GRANTED;
                  }
              }
          }
      }
      return VoterInterface::ACCESS_ABSTAIN;
  }
  </code></pre>