src/Security/Voter/Document/ViewVoter.php line 12

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Security\Voter\Document;
  4. use App\Data\Document\Document;
  5. use App\Data\Office\Office;
  6. use App\Security\Voter\HasRoleForSubjectVoter;
  7. class ViewVoter extends HasRoleForSubjectVoter
  8. {
  9.     protected function getRequiredRole(): string
  10.     {
  11.         return 'OFFICE_DOCUMENT_VIEW';
  12.     }
  13.     protected function getSubject(): string
  14.     {
  15.         return Document::class;
  16.     }
  17.     /**
  18.      * @param Document $subject
  19.      */
  20.     protected function getOffice($subject): ?Office
  21.     {
  22.         return $subject->getPatient()->getOffice();
  23.     }
  24. }