src/Security/Api/Authorization/Voter/JobLab/CaseEntityValidationVoter.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Security\Api\Authorization\Voter\JobLab;
  3. use App\Helper\Api\Entity\RequestDataContainer;
  4. use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
  5. use App\Security\Api\Authorization\VoterAttribute\JobLab\CaseEntityVoterAttribute;
  6. use App\Validator\Api\Data\CoreModule\EmployeeDataValidator;
  7. use App\Validator\Api\Data\CoreModule\OrgUnitDataValidator;
  8. use App\Validator\Api\Data\JobLab\CaseEntityDataValidator;
  9. use App\Validator\Api\Data\JobLab\MatchingDataValidator;
  10. use App\Validator\Api\Data\JobLab\MatchingRejectionDataValidator;
  11. /**
  12.  * Validation voter.
  13.  *
  14.  * @package API
  15.  * @internal
  16.  */
  17. class CaseEntityValidationVoter extends AbstractCrudValidationVoter
  18. {
  19.     /**
  20.      * Employee validator interface.
  21.      *
  22.      * @var EmployeeDataValidator
  23.      */
  24.     protected EmployeeDataValidator $employeeDataValidator;
  25.     /**
  26.      * Matching validator interface.
  27.      *
  28.      * @var MatchingDataValidator
  29.      */
  30.     protected MatchingDataValidator $matchingDataValidator;
  31.     /**
  32.      * Matching rejection validator interface.
  33.      *
  34.      * @var MatchingRejectionDataValidator
  35.      */
  36.     protected MatchingRejectionDataValidator $matchingRejectionDataValidator;
  37.     /**
  38.      * Organizational unit validator interface.
  39.      *
  40.      * @var OrgUnitDataValidator
  41.      */
  42.     protected OrgUnitDataValidator $orgUnitDataValidator;
  43.     /**
  44.      * Constructor.
  45.      *
  46.      * @param CaseEntityDataValidator $validator The standard validator.
  47.      * @param EmployeeDataValidator $employeeDataValidator The employee validator.
  48.      * @param OrgUnitDataValidator $orgUnitDataValidator The organizational unit validator.
  49.      * @param MatchingDataValidator $matchingDataValidator The matching validator.
  50.      * @param MatchingRejectionDataValidator $matchingRejectionDataValidator The matching rejection validator.
  51.      */
  52.     public function __construct(
  53.         CaseEntityDataValidator $validator,
  54.         EmployeeDataValidator $employeeDataValidator,
  55.         OrgUnitDataValidator $orgUnitDataValidator,
  56.         MatchingDataValidator $matchingDataValidator,
  57.         MatchingRejectionDataValidator $matchingRejectionDataValidator
  58.     ) {
  59.         // prevent false-positive php:S1185
  60.         $this->validator $validator;
  61.         parent::__construct($validator);
  62.         $this->employeeDataValidator $employeeDataValidator;
  63.         $this->orgUnitDataValidator $orgUnitDataValidator;
  64.         $this->matchingDataValidator $matchingDataValidator;
  65.         $this->matchingRejectionDataValidator $matchingRejectionDataValidator;
  66.     }
  67.     /**
  68.      * Returns list of supported attributes.
  69.      *
  70.      * @return array
  71.      * @noinspection PhpClassConstantAccessedViaChildClassInspection
  72.      */
  73.     protected function getSupportedAttributes(): array
  74.     {
  75.         return [
  76.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_HOMEPAGE),
  77.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_CREATE),
  78.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_CREATE_MATCHING_SUCCESSFUL),
  79.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_DELETE),
  80.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST),
  81.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_EMPLOYEE),
  82.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_ORG_UNIT),
  83.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCH),
  84.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_CONFIGURATION_READ),
  85.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_CONFIGURATION_UPDATE),
  86.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_REJECTION_CREATE),
  87.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_REJECTION_DELETE),
  88.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_REJECTION_SET_DIRTY),
  89.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_READ),
  90.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_READ_ORG_UNIT),
  91.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_REQUEST_SKILL_SCREENING),
  92.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE),
  93.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS),
  94.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE_WORKFLOW_STATUS),
  95.             CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_EMPLOYEE_HISTORY_LIST)
  96.         ];
  97.     }
  98.     /**
  99.      * Validation check.
  100.      *
  101.      * @param RequestDataContainer $subject The request data object to validate.
  102.      */
  103.     protected function listEmployee(RequestDataContainer $subject): void
  104.     {
  105.         $this->employeeDataValidator->validateInputList($subject->getInput());
  106.     }
  107.     /**
  108.      * Validation check.
  109.      *
  110.      * @param RequestDataContainer $subject The request data object to validate.
  111.      */
  112.     protected function listOrgUnit(RequestDataContainer $subject): void
  113.     {
  114.         $this->orgUnitDataValidator->validateInputList($subject->getInput());
  115.     }
  116.     /**
  117.      * Validation check.
  118.      *
  119.      * @param RequestDataContainer $subject The request data object to validate.
  120.      */
  121.     protected function match(RequestDataContainer $subject): void
  122.     {
  123.         $this->matchingDataValidator->validateInputList($subject->getInput());
  124.     }
  125.     /**
  126.      * Validation check.
  127.      *
  128.      * @param RequestDataContainer $subject The request data object to validate.
  129.      */
  130.     protected function matchingConfigurationRead(RequestDataContainer $subject): void
  131.     {
  132.         $this->validator->validateInputMatchingConfigurationRead($subject->getInput());
  133.     }
  134.     /**
  135.      * Validation check.
  136.      *
  137.      * @param RequestDataContainer $subject The request data object to validate.
  138.      */
  139.     protected function matchingConfigurationUpdate(RequestDataContainer $subject): void
  140.     {
  141.         $this->validator->validateInputMatchingConfigurationUpdate($subject->getInput());
  142.     }
  143.     /**
  144.      * Validation check.
  145.      *
  146.      * @param RequestDataContainer $subject The request data object to validate.
  147.      */
  148.     protected function matchingRejectionCreate(RequestDataContainer $subject): void
  149.     {
  150.         $this->matchingRejectionDataValidator->validateInputCreate($subject->getInput());
  151.     }
  152.     /**
  153.      * Validation check.
  154.      *
  155.      * @param RequestDataContainer $subject The request data object to validate.
  156.      */
  157.     protected function matchingRejectionDelete(RequestDataContainer $subject): void
  158.     {
  159.         $this->matchingRejectionDataValidator->validateInputDelete($subject->getInput());
  160.     }
  161.     /**
  162.      * Validation check.
  163.      *
  164.      * @param RequestDataContainer $subject The request data object to validate.
  165.      */
  166.     protected function matchingRejectionSetDirty(RequestDataContainer $subject): void
  167.     {
  168.         $this->matchingRejectionDataValidator->validateInputSetDirty($subject->getInput());
  169.     }
  170.     /**
  171.      * Validation check.
  172.      *
  173.      * @param RequestDataContainer $subject The request data object to validate.
  174.      */
  175.     protected function readOrgUnit(RequestDataContainer $subject): void
  176.     {
  177.         $this->orgUnitDataValidator->validateInputRead($subject->getInput());
  178.     }
  179.     /**
  180.      * Validation check.
  181.      *
  182.      * @param RequestDataContainer $subject The request data object to validate.
  183.      */
  184.     protected function requestSkillScreening(RequestDataContainer $subject): void
  185.     {
  186.         $this->validator->validateInputRequestSkillScreening($subject->getInput());
  187.     }
  188.     /**
  189.      * Validation check.
  190.      *
  191.      * @param RequestDataContainer $subject The request data object to validate.
  192.      */
  193.     protected function updateWorkflowStatus(RequestDataContainer $subject): void
  194.     {
  195.         $this->validator->validateInputUpdateWorkflowStatus($subject->getInput());
  196.     }
  197.     /**
  198.      * Validation check.
  199.      *
  200.      * @param RequestDataContainer $subject The request data object to validate.
  201.      */
  202.     protected function homepage(RequestDataContainer $subject): void
  203.     {
  204.     }
  205.     /**
  206.      * Validation check.
  207.      *
  208.      * @param RequestDataContainer $subject The request data object to validate.
  209.      */
  210.     protected function createMatchingSuccessful(RequestDataContainer $subject): void
  211.     {
  212.         $this->validator->validateInputCreateMatchingSuccessful($subject->getInput());
  213.     }
  214.     /**
  215.      * Validation check.
  216.      *
  217.      * @param RequestDataContainer $subject The request data object to validate.
  218.      */
  219.     protected function employeeHistoryList(RequestDataContainer $subject): void
  220.     {
  221.         $this->validator->validateInputList($subject->getInput());
  222.     }
  223. }