<?php
declare(strict_types=1);
/**
* SubscriptionPlanVoter.php File.
* This file is part of the Payment.net Project.
*
* PHP version 5
*
* @category Public Api
* @package Bdm\BackofficeBundle\Security\Authorization\Voter
* @author Pavel Baraulya <pbaraulya@bdmultimedia.fr>
* @link http://www.payment.net/
*
* FEATURES :
* ==========
*
* TODO-LIST :
* ===========
*
* HISTORY :
* =========
* 20150709 - Pavel Baraulya
*
**/
namespace Bdm\PublicApiBundle\Security\Authorization\Voter;
use Bdm\CheckoutBundle\Entity\SubscriptionPlan;
use Doctrine\Common\Util\ClassUtils;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/**
* Voter for subscription plans
*/
class SubscriptionPlanVoter extends AbstractVoter
{
/**
* @param string $sAttribute attribute
* @param mixed $oSubject subject
* @return bool
*/
public function supports($sAttribute, $oSubject)
{
return $oSubject instanceof SubscriptionPlan;
}
/**
* @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->getApplication()->getId() == $oApplication->getId();
}
}