src/Security/Voter/ObjectManagement/ObjectsunitVoter.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Security\Voter\ObjectManagement;
  3. use App\Daikin\BaseBundle\Entity\Objectsunit;
  4. use App\Security\Voter\SubjectCompanyOwnerVoterTrait;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  7. class ObjectsunitVoter extends Voter
  8. {
  9.     use SubjectCompanyOwnerVoterTrait;
  10.     protected function supports(string $attribute$subject): bool
  11.     {
  12.         return $subject instanceof Objectsunit;
  13.     }
  14.     public function supportsAttribute(string $attribute): bool
  15.     {
  16.         return $attribute === 'CRUD';
  17.     }
  18.     public function supportsType(string $subjectType): bool
  19.     {
  20.         return is_a($subjectTypeObjectsunit::class, true);
  21.     }
  22.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  23.     {
  24.         return $this->companyOwnsSubject($token->getUser(), $subject);
  25.     }
  26. }