<?php
namespace App\Security\Api\Authorization\Voter\JobLab;
use App\Helper\Api\Entity\RequestDataContainer;
use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
use App\Security\Api\Authorization\VoterAttribute\JobLab\CaseEntityVoterAttribute;
use App\Validator\Api\Data\CoreModule\EmployeeDataValidator;
use App\Validator\Api\Data\CoreModule\OrgUnitDataValidator;
use App\Validator\Api\Data\JobLab\CaseEntityDataValidator;
use App\Validator\Api\Data\JobLab\MatchingDataValidator;
use App\Validator\Api\Data\JobLab\MatchingRejectionDataValidator;
/**
* Validation voter.
*
* @package API
* @internal
*/
class CaseEntityValidationVoter extends AbstractCrudValidationVoter
{
/**
* Employee validator interface.
*
* @var EmployeeDataValidator
*/
protected EmployeeDataValidator $employeeDataValidator;
/**
* Matching validator interface.
*
* @var MatchingDataValidator
*/
protected MatchingDataValidator $matchingDataValidator;
/**
* Matching rejection validator interface.
*
* @var MatchingRejectionDataValidator
*/
protected MatchingRejectionDataValidator $matchingRejectionDataValidator;
/**
* Organizational unit validator interface.
*
* @var OrgUnitDataValidator
*/
protected OrgUnitDataValidator $orgUnitDataValidator;
/**
* Constructor.
*
* @param CaseEntityDataValidator $validator The standard validator.
* @param EmployeeDataValidator $employeeDataValidator The employee validator.
* @param OrgUnitDataValidator $orgUnitDataValidator The organizational unit validator.
* @param MatchingDataValidator $matchingDataValidator The matching validator.
* @param MatchingRejectionDataValidator $matchingRejectionDataValidator The matching rejection validator.
*/
public function __construct(
CaseEntityDataValidator $validator,
EmployeeDataValidator $employeeDataValidator,
OrgUnitDataValidator $orgUnitDataValidator,
MatchingDataValidator $matchingDataValidator,
MatchingRejectionDataValidator $matchingRejectionDataValidator
) {
// prevent false-positive php:S1185
$this->validator = $validator;
parent::__construct($validator);
$this->employeeDataValidator = $employeeDataValidator;
$this->orgUnitDataValidator = $orgUnitDataValidator;
$this->matchingDataValidator = $matchingDataValidator;
$this->matchingRejectionDataValidator = $matchingRejectionDataValidator;
}
/**
* Returns list of supported attributes.
*
* @return array
* @noinspection PhpClassConstantAccessedViaChildClassInspection
*/
protected function getSupportedAttributes(): array
{
return [
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_HOMEPAGE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_CREATE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_CREATE_MATCHING_SUCCESSFUL),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_DELETE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_EMPLOYEE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_ORG_UNIT),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCH),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_CONFIGURATION_READ),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_CONFIGURATION_UPDATE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_REJECTION_CREATE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_REJECTION_DELETE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_MATCHING_REJECTION_SET_DIRTY),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_READ),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_READ_ORG_UNIT),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_REQUEST_SKILL_SCREENING),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE_WORKFLOW_STATUS),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_EMPLOYEE_HISTORY_LIST)
];
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function listEmployee(RequestDataContainer $subject): void
{
$this->employeeDataValidator->validateInputList($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function listOrgUnit(RequestDataContainer $subject): void
{
$this->orgUnitDataValidator->validateInputList($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function match(RequestDataContainer $subject): void
{
$this->matchingDataValidator->validateInputList($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function matchingConfigurationRead(RequestDataContainer $subject): void
{
$this->validator->validateInputMatchingConfigurationRead($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function matchingConfigurationUpdate(RequestDataContainer $subject): void
{
$this->validator->validateInputMatchingConfigurationUpdate($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function matchingRejectionCreate(RequestDataContainer $subject): void
{
$this->matchingRejectionDataValidator->validateInputCreate($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function matchingRejectionDelete(RequestDataContainer $subject): void
{
$this->matchingRejectionDataValidator->validateInputDelete($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function matchingRejectionSetDirty(RequestDataContainer $subject): void
{
$this->matchingRejectionDataValidator->validateInputSetDirty($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function readOrgUnit(RequestDataContainer $subject): void
{
$this->orgUnitDataValidator->validateInputRead($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function requestSkillScreening(RequestDataContainer $subject): void
{
$this->validator->validateInputRequestSkillScreening($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function updateWorkflowStatus(RequestDataContainer $subject): void
{
$this->validator->validateInputUpdateWorkflowStatus($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function homepage(RequestDataContainer $subject): void
{
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function createMatchingSuccessful(RequestDataContainer $subject): void
{
$this->validator->validateInputCreateMatchingSuccessful($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function employeeHistoryList(RequestDataContainer $subject): void
{
$this->validator->validateInputList($subject->getInput());
}
}