src/Security/Api/Authorization/Voter/Cmr/CaseEntityValidationVoter.php line 19

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