vendor/oneup/uploader-bundle/src/EventListener/DisallowedMimetypeValidationListener.php line 12

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Oneup\UploaderBundle\EventListener;
  4. use Oneup\UploaderBundle\Event\ValidationEvent;
  5. use Oneup\UploaderBundle\Uploader\Exception\ValidationException;
  6. class DisallowedMimetypeValidationListener
  7. {
  8.     public function onValidate(ValidationEvent $event): void
  9.     {
  10.         $config $event->getConfig();
  11.         $file $event->getFile();
  12.         if (=== \count($config['disallowed_mimetypes'])) {
  13.             return;
  14.         }
  15.         $mimetype $file->getExtension();
  16.         if (\in_array($mimetype$config['disallowed_mimetypes'], true)) {
  17.             throw new ValidationException('error.blacklist');
  18.         }
  19.     }
  20. }