vendor/wearemarketing/ecommercebundle/Voter/AddressVoter.php line 12

Open in your IDE?
  1. <?php
  2. namespace WAM\Bundle\EcommerceBundle\Voter;
  3. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  4. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  5. use WAM\Bundle\EcommerceBundle\Entity\Interfaces\AddressInterface;
  6. /**
  7.  * @author Juanjo Martínez <jmartinez@wearemarketing.com>
  8.  */
  9. class AddressVoter extends Voter
  10. {
  11.     const EDIT 'EDIT';
  12.     const DELETE 'DELETE';
  13.     protected function supports($attribute$subject)
  14.     {
  15.         if (!in_array($attribute, [self::EDITself::DELETE])) {
  16.             return false;
  17.         }
  18.         if (!$subject instanceof AddressInterface) {
  19.             return false;
  20.         }
  21.         return true;
  22.     }
  23.     protected function voteOnAttribute($attribute$subjectTokenInterface $token)
  24.     {
  25.         return $token->getUser() == $subject->getCustomer();
  26.     }
  27. }