vendor/symfony/security-bundle/EventListener/VoteListener.php line 37

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\SecurityBundle\EventListener;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
  13. use Symfony\Component\Security\Core\Event\VoteEvent;
  14. /**
  15.  * Listen to vote events from traceable voters.
  16.  *
  17.  * @author Laurent VOULLEMIER <laurent.voullemier@gmail.com>
  18.  *
  19.  * @internal
  20.  */
  21. class VoteListener implements EventSubscriberInterface
  22. {
  23.     private $traceableAccessDecisionManager;
  24.     public function __construct(TraceableAccessDecisionManager $traceableAccessDecisionManager)
  25.     {
  26.         $this->traceableAccessDecisionManager $traceableAccessDecisionManager;
  27.     }
  28.     /**
  29.      * Event dispatched by a voter during access manager decision.
  30.      */
  31.     public function onVoterVote(VoteEvent $event)
  32.     {
  33.         $this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote());
  34.     }
  35.     public static function getSubscribedEvents(): array
  36.     {
  37.         return ['debug.security.authorization.vote' => 'onVoterVote'];
  38.     }
  39. }