<?php
namespace App\Security\Api\Authorization\Voter\SkillScreening;
use App\Helper\Api\Entity\RequestDataContainer;
use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
use App\Security\Api\Authorization\VoterAttribute\SkillScreening\CaseEntityVoterAttribute;
use App\Validator\Api\Data\CoreModule\EmployeeDataValidator;
use App\Validator\Api\Data\SkillScreening\CaseEntityDataValidator;
/**
* Validation voter.
*
* @package API
* @internal
*/
class CaseEntityValidationVoter extends AbstractCrudValidationVoter
{
/**
* Employee validator interface.
*
* @var EmployeeDataValidator
*/
protected EmployeeDataValidator $employeeDataValidator;
/**
* Constructor.
*
* @param CaseEntityDataValidator $validator The standard validator.
* @param EmployeeDataValidator $employeeDataValidator The employee validator.
*/
public function __construct(CaseEntityDataValidator $validator, EmployeeDataValidator $employeeDataValidator)
{
// prevent false-positive php:S1185
$this->validator = $validator;
parent::__construct($validator);
$this->employeeDataValidator = $employeeDataValidator;
}
/**
* Returns list of supported attributes.
*
* @return array
* @noinspection PhpClassConstantAccessedViaChildClassInspection
*/
protected function getSupportedAttributes(): array
{
return [
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_CREATE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_DELETE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_EMPLOYEE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_READ),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_READ_BY_EMPLOYEE_ID),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS)
];
}
/**
* 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 readByEmployeeId(RequestDataContainer $subject): void
{
$this->validator->validateInputReadByEmployeeId($subject->getInput());
}
}