<?php
namespace App\Security\Api\Authorization\Voter\CoreModule;
use App\Helper\Api\Entity\RequestDataContainer;
use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
use App\Security\Api\Authorization\VoterAttribute\CoreModule\OrgUnitVoterAttribute;
use App\Validator\Api\Data\CoreModule\OrgUnitDataValidator;
/**
* Validation voter.
*
* @package API
* @internal
*/
class OrgUnitValidationVoter extends AbstractCrudValidationVoter
{
/**
* Constructor.
*
* @param OrgUnitDataValidator $validator The standard validator.
*/
public function __construct(OrgUnitDataValidator $validator)
{
// prevent false-positive php:S1185
$this->validator = $validator;
parent::__construct($validator);
}
/**
* Returns list of supported attributes.
*
* @return array
* @noinspection PhpClassConstantAccessedViaChildClassInspection
*/
protected function getSupportedAttributes(): array
{
return [
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_CREATE),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_DELETE),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_LIST),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_LIST_TREE),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_READ),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_READ_TREE),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_UPDATE),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS),
OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_MODULE_DEPENDENCY)
];
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function listTree(RequestDataContainer $subject): void
{
$this->validator->validateInputListTree($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function readTree(RequestDataContainer $subject): void
{
$this->validator->validateInputReadTree($subject->getInput());
}
/**
* Validation check.
*
* @param RequestDataContainer $subject The request data object to validate.
*/
protected function moduleDependency(RequestDataContainer $subject): void
{
// no op
}
}