FileSanitizationEventSubscriber.php
Same filename in other branches
Namespace
Drupal\file_validator_test\EventSubscriberFile
-
core/
modules/ file/ tests/ modules/ file_validator_test/ src/ EventSubscriber/ FileSanitizationEventSubscriber.php
View source
<?php
namespace Drupal\file_validator_test\EventSubscriber;
use Drupal\Core\File\Event\FileUploadSanitizeNameEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Provides a file sanitization listener for file upload tests.
*/
class FileSanitizationEventSubscriber implements EventSubscriberInterface {
/**
* The allowed extensions.
*
* @var string[]
*/
protected array $allowedExtensions = [];
/**
* Handles the file sanitization event.
*/
public function onFileSanitization(FileUploadSanitizeNameEvent $event) {
$this->allowedExtensions = $event->getAllowedExtensions();
}
/**
* Gets the allowed extensions.
*
* @return string[]
* The allowed extensions.
*/
public function getAllowedExtensions() : array {
return $this->allowedExtensions;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
return [
FileUploadSanitizeNameEvent::class => 'onFileSanitization',
];
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
FileSanitizationEventSubscriber | Provides a file sanitization listener for file upload tests. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.