src/Security/Api/Authorization/Voter/WorkplaceConfigurator/WorkplaceScreeningValidationVoter.php line 16

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