<?php
namespace App\Security\Api\Authorization\Voter\Cmr;
use App\Helper\Api\Entity\RequestDataContainer;
use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
use App\Security\Api\Authorization\VoterAttribute\Cmr\CaseEntityVoterAttribute;
use App\Validator\Api\Data\CoreModule\EmployeeDataValidator;
use App\Validator\Api\Data\CoreModule\OrgUnitDataValidator;
use App\Validator\Api\Data\Cmr\CaseEntityDataValidator;
/**
* Validation voter.
*
* @package API
* @author fmt.hodzic
* @internal
*/
class CaseEntityValidationVoter extends AbstractCrudValidationVoter
{
/**
* Employee validator interface.
*
* @var EmployeeDataValidator
*/
private 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;
$this->employeeDataValidator = $employeeDataValidator;
parent::__construct($validator);
}
/**
* Returns a 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_READ),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_UPDATE),
CaseEntityVoterAttribute::getAttribute(
CaseEntityVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS
),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_EMPLOYEE),
];
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function listEmployee(RequestDataContainer $subject): void
{
$this->employeeDataValidator->validateInputList($subject->getInput());
}
}