src/Security/Api/Authorization/Voter/SkillScreening/CaseEntityValidationVoter.php line 17

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