<?php
declare(strict_types=1);
namespace Bdm\PublicApiBundle\Security\Authorization\Voter;
use Bdm\CheckoutBundle\Entity\Transaction;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
class TransactionVoter extends AbstractVoter
{
/**
* @param string $sAttribute attribute
* @param mixed $oSubject subject
* @return bool
*/
public function supports($sAttribute, $oSubject)
{
return $oSubject instanceof Transaction;
}
/**
* @param string $sAttr attr
* @param mixed $mEntity entity
* @param TokenInterface $oToken token
*
* @return bool
*/
protected function voteOnAttribute($sAttr, $mEntity, TokenInterface $oToken)
{
$oApplication = $this->getApplication($oToken);
return $mEntity->getPayment()->getApplication() === $oApplication;
}
}