title: Using multiple voters from different bundles in Symfony2
body: <p>I have initially created a voter in one of my bundles and have used it without a problem. But, I've created another one in another bundle, because it uses different classes and the way it's going to decide if to let users pass is different. </p>
  
  <p>The problem is that this second voter is not detected despite the fact that I've followed the exact same steps as for the first one.</p>
  
  <p>What am I doing wrong? Is it possible to create and use only one single voter?</p>
  
  <p>So this is the first one that worked properly, I did it exactly like the documentation says.</p>
  
  <p>Register it as a service</p>
  
  <pre><code>services:
    security.access.support_voter:
        class:      SupportMessageBundle\Security\Voter\SupportVoter
        public:     false
        tags:
            - { name: security.voter }
  </code></pre>
  
  <p>Create it. Short explanation of what it does: Checks the curent user's role regarding my <code>SupportMessageBundle</code>, a bundle for managing support tickets. I also have a constant that checks if the Ticket was started by the user.</p>
  
  <pre><code>namespace SupportMessageBundle\Security\Voter;
  
  use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter;
  use MedAppBundle\Entity\User;
  use Symfony\Component\Security\Core\User\UserInterface;
  
  class SupportVoter extends AbstractVoter
  {
      const SUPPORT = 'support';
      const SUPERADMIN = 'superadmin';
      const MEDIC = 'medic';
      const ISMINE = 'ismine';
      /* const EDIT = 'edit';*/
  
      protected function getSupportedAttributes()
      {
          return array(self::SUPPORT, self::SUPERADMIN,self::MEDIC,self::ISMINE/*, self::EDIT*/);
      }
  
      protected function getSupportedClasses()
      {
          return array('MedAppBundle\Entity\User','SupportMessageBundle\Entity\Ticket');
      }
  
      protected function isGranted($attribute, $object, $user = null)
      {
          // make sure there is a user object (i.e. that the user is logged in)
          if (!$user instanceof UserInterface) {
              return false;
          }
  
          // double-check that the User object is the expected entity.
          // It always will be, unless there is some misconfiguration of the
          // security system.
          if (!$user instanceof User) {
              throw new \LogicException('The user is somehow not our User class!');
          }
  
          switch ($attribute) {
              case self::SUPPORT:
                  // the data object could have for example a method isPrivate()
                  // which checks the Boolean attribute $private
              {
  
                  if ($user-&gt;hasRole('ROLE_SUPPORT')||$user-&gt;hasRole('ROLE_SUPER_ADMIN')) {
                      return true;
                  }
              }
  
                  break;
              case self::SUPERADMIN:
                  // the data object could have for example a method isPrivate()
                  // which checks the Boolean attribute $private
              {
  
                  if ($user-&gt;hasRole('ROLE_SUPER_ADMIN')) {
                      return true;
                  }
              }
  
                  break;
              /*case self::EDIT:
                  // this assumes that the data object has a getOwner() method
                  // to get the entity of the user who owns this data object
                  if ($user-&gt;getId() === $post-&gt;getOwner()-&gt;getId()) {
                      return true;
                  }
  
                  break;*/
              case self::MEDIC:
                  // the data object could have for example a method isPrivate()
                  // which checks the Boolean attribute $private
              {
  
                  if ($user-&gt;hasRole('ROLE_MEDIC')) {
                      return true;
                  }
              }
  
                  break;
  
              case self::ISMINE:
                  // the data object could have for example a method isPrivate()
                  // which checks the Boolean attribute $private
              {
  
                  if ($user == $object-&gt;getSender()) {
                      return true;
                  }
              }
  
                  break;
          }
  
          return false;
      }
  }
  </code></pre>
  
  <p>As for the second one,</p>
  
  <p>I register it as a service as well, in the other bundle's <code>services.yml</code>:</p>
  
  <pre><code>services:
  
      security.access.features_voter:
          class:      MedAppBundle\Security\Voter\FeaturesVoter
          public:     false
          tags:
              - { name: security.voter }
  </code></pre>
  
  <p>And this time I'm not checking anything, I just return <code>true</code>, but calling it returns me <code>false</code> every single time, so something is clearly wrong.</p>
  
  <pre><code>namespace MedAppBundle\Security\Voter;
  
  use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter;
  
  
  class FeaturesVoter extends AbstractVoter
  {
      const ISMINE = 'ismine';
  
  
      protected function getSupportedAttributes()
      {
          return array(self::ISMINE);
      }
  
      protected function getSupportedClasses()
      {
          return array('MedAppBundle/Entity/Features');
      }
  
      public function isGranted($attribute, $object, $user = null)
      {
         return true;
      }
  }
  </code></pre>
  
  <p>The ways I tried calling it were:</p>
  
  <pre><code>$this-&gt;isGranted('issmine',$id); //returns false
  $this-&gt;denyAccessUnlessGranted('issmine', $id, 'Unauthorized access!'); //denies access
  </code></pre>
  
  <p><code>$id</code> is a <code>Feature</code> object and this is from a controller in the <code>MedAppBundle</code> that contains the <code>Feature</code> Entity.</p>
  
  <p>The first voter, however, works properly, so I must be doing something wrong in this one's declarations, or it's not possible to have more than one.</p>
  
  <p>debug:container doesn't list them, not even the working one. The bundles are loaded in Kernel because I've been using controllers and other things from them, just the services seem to not work. All bundles have <code>$loader-&gt;load('services.yml');</code> inside the DependencyInjection directory in the BundlenameExtension.php file</p>