src/Security/Api/Authorization/Voter/SocialCounseling/CaseEntityValidationVoter.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Security\Api\Authorization\Voter\SocialCounseling;
  3. use App\Helper\Api\Entity\RequestDataContainer;
  4. use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
  5. use App\Security\Api\Authorization\VoterAttribute\SocialCounseling\CaseEntityVoterAttribute;
  6. use App\Validator\Api\Data\CoreModule\EmployeeDataValidator;
  7. use App\Validator\Api\Data\SocialCounseling\CaseEntityDataValidator;
  8. /**
  9.  * Validation voter.
  10.  *
  11.  * @package API
  12.  * @author fmt.hodzic
  13.  * @internal
  14.  */
  15. class CaseEntityValidationVoter extends AbstractCrudValidationVoter
  16. {
  17.     /**
  18.      * Employee validator interface.
  19.      *
  20.      * @var EmployeeDataValidator
  21.      */
  22.     protected EmployeeDataValidator $employeeDataValidator;
  23.     /**
  24.      * Constructor.
  25.      *
  26.      * @param CaseEntityDataValidator $validator The standard validator.
  27.      * @param EmployeeDataValidator $employeeDataValidator The employee validator.
  28.      */
  29.     public function __construct(CaseEntityDataValidator $validatorEmployeeDataValidator $employeeDataValidator)
  30.     {
  31.         // prevent false-positive php:S1185
  32.         $this->validator $validator;
  33.         parent::__construct($validator);
  34.         $this->employeeDataValidator $employeeDataValidator;
  35.     }
  36.     /**
  37.      * Returns list of supported attributes.
  38.      *
  39.      * @return array
  40.      * @noinspection PhpClassConstantAccessedViaChildClassInspection
  41.      */
  42.     protected function getSupportedAttributes(): array
  43.     {
  44.         return [
  45.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_HOMEPAGE),
  46.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_CREATE),
  47.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_DELETE),
  48.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_EMPLOYEE),
  49.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST),
  50.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_READ),
  51.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE),
  52.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS),
  53.         ];
  54.     }
  55.     /**
  56.      * Validation check.
  57.      *
  58.      * @param RequestDataContainer $subject The request data object to validate.
  59.      */
  60.     protected function listEmployee(RequestDataContainer $subject): void
  61.     {
  62.         $this->employeeDataValidator->validateInputList($subject->getInput());
  63.     }
  64.     /**
  65.      * Validation check.
  66.      *
  67.      * @param RequestDataContainer $subject The request data object to validate.
  68.      */
  69.     protected function homepage(RequestDataContainer $subject): void
  70.     {
  71.     }
  72. }