src/Security/Api/Authorization/Voter/CoreModule/OrgUnitValidationVoter.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Security\Api\Authorization\Voter\CoreModule;
  3. use App\Helper\Api\Entity\RequestDataContainer;
  4. use App\Security\Api\Authorization\Voter\AbstractCrudValidationVoter;
  5. use App\Security\Api\Authorization\VoterAttribute\CoreModule\OrgUnitVoterAttribute;
  6. use App\Validator\Api\Data\CoreModule\OrgUnitDataValidator;
  7. /**
  8.  * Validation voter.
  9.  *
  10.  * @package API
  11.  * @internal
  12.  */
  13. class OrgUnitValidationVoter extends AbstractCrudValidationVoter
  14. {
  15.     /**
  16.      * Constructor.
  17.      *
  18.      * @param OrgUnitDataValidator $validator The standard validator.
  19.      */
  20.     public function __construct(OrgUnitDataValidator $validator)
  21.     {
  22.         // prevent false-positive php:S1185
  23.         $this->validator $validator;
  24.         parent::__construct($validator);
  25.     }
  26.     /**
  27.      * Returns list of supported attributes.
  28.      *
  29.      * @return array
  30.      * @noinspection PhpClassConstantAccessedViaChildClassInspection
  31.      */
  32.     protected function getSupportedAttributes(): array
  33.     {
  34.         return [
  35.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_CREATE),
  36.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_DELETE),
  37.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_LIST),
  38.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_LIST_TREE),
  39.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_READ),
  40.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_READ_TREE),
  41.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_UPDATE),
  42.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_UPDATE_ACTIVE_STATUS),
  43.             OrgUnitVoterAttribute::getAttribute(OrgUnitVoterAttribute::METHOD_ID_MODULE_DEPENDENCY)
  44.         ];
  45.     }
  46.     /**
  47.      * Validation check.
  48.      *
  49.      * @param RequestDataContainer $subject The request data object to validate.
  50.      */
  51.     protected function listTree(RequestDataContainer $subject): void
  52.     {
  53.         $this->validator->validateInputListTree($subject->getInput());
  54.     }
  55.     /**
  56.      * Validation check.
  57.      *
  58.      * @param RequestDataContainer $subject The request data object to validate.
  59.      */
  60.     protected function readTree(RequestDataContainer $subject): void
  61.     {
  62.         $this->validator->validateInputReadTree($subject->getInput());
  63.     }
  64.     /**
  65.      * Validation check.
  66.      *
  67.      * @param RequestDataContainer $subject The request data object to validate.
  68.      */
  69.     protected function moduleDependency(RequestDataContainer $subject): void
  70.     {
  71.         // no op
  72.     }
  73. }