<?php
namespace App\Security\Api\Authorization\Voter\SocialCounseling;
use App\Helper\Api\Entity\RequestDataContainer;
use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
use App\Security\Api\Authorization\VoterAttribute\SocialCounseling\CaseEntityVoterAttribute;
use App\Validator\Api\Data\CoreModule\EmployeeDataValidator;
use App\Validator\Api\Data\SocialCounseling\CaseEntityDataValidator;
/**
* Validation voter.
*
* @package API
* @author fmt.hodzic
* @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_HOMEPAGE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_CREATE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_DELETE),
CaseEntityVoterAttribute::getAttribute(CaseEntityVoterAttribute::METHOD_ID_LIST_EMPLOYEE),
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),
];
}
/**
* 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 homepage(RequestDataContainer $subject): void
{
}
}