<?php
namespace App\Security\Api\Authorization\Voter\WorkplaceConfigurator;
use App\Helper\Api\Entity\RequestDataContainer;
use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
use App\Security\Api\Authorization\VoterAttribute\WorkplaceConfigurator\WorkplaceScreeningVoterAttribute;
use App\Validator\Api\Data\WorkplaceConfigurator\WorkplaceScreeningDataValidator;
/**
* Validation voter.
*
* @package API
* @internal
*/
class WorkplaceScreeningValidationVoter extends AbstractCrudValidationVoter
{
/**
* Constructor.
*
* @param WorkplaceScreeningDataValidator $validator The standard validator.
*/
public function __construct(WorkplaceScreeningDataValidator $validator)
{
// prevent false-positive php:S1185
$this->validator = $validator;
parent::__construct($validator);
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function activate(RequestDataContainer $subject): void
{
$this->validator->validateInputActivate($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function copy(RequestDataContainer $subject): void
{
$this->validator->validateInputCopy($subject->getInput());
}
/**
* Returns list of supported attributes.
*
* @return array
* @noinspection PhpClassConstantAccessedViaChildClassInspection
*/
protected function getSupportedAttributes(): array
{
return [
WorkplaceScreeningVoterAttribute::getAttribute(WorkplaceScreeningVoterAttribute::METHOD_ID_ACTIVATE),
WorkplaceScreeningVoterAttribute::getAttribute(WorkplaceScreeningVoterAttribute::METHOD_ID_COPY),
WorkplaceScreeningVoterAttribute::getAttribute(WorkplaceScreeningVoterAttribute::METHOD_ID_CREATE),
WorkplaceScreeningVoterAttribute::getAttribute(WorkplaceScreeningVoterAttribute::METHOD_ID_DELETE),
WorkplaceScreeningVoterAttribute::getAttribute(WorkplaceScreeningVoterAttribute::METHOD_ID_LIST),
WorkplaceScreeningVoterAttribute::getAttribute(WorkplaceScreeningVoterAttribute::METHOD_ID_READ),
WorkplaceScreeningVoterAttribute::getAttribute(WorkplaceScreeningVoterAttribute::METHOD_ID_UPDATE),
WorkplaceScreeningVoterAttribute::getAttribute(
WorkplaceScreeningVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS
)
];
}
}