Skip to content
Snippets Groups Projects

Issue #3458479: Require at least Drupal 10.3 and remove any usage of deprecated classes, methods, constants, or functions

Merged Issue #3458479: Require at least Drupal 10.3 and remove any usage of deprecated classes, methods, constants, or functions
2 files
+ 31
9
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -2,6 +2,7 @@
namespace Drupal\file_example;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\File\Event\FileUploadSanitizeNameEvent;
use Drupal\Core\File\FileExists;
use Drupal\Core\File\FileSystemInterface;
@@ -37,6 +38,8 @@ class FileExampleSubmitHandlerHelper {
* The file system.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
* The event dispatcher.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The module handler.
*
* @see https://php.watch/versions/8.0/constructor-property-promotion
*/
@@ -47,7 +50,8 @@ public function __construct(
protected MessengerInterface $messenger,
protected FileRepositoryInterface $fileRepository,
protected FileSystemInterface $fileSystem,
protected EventDispatcherInterface $eventDispatcher
protected EventDispatcherInterface $eventDispatcher,
protected ModuleHandlerInterface $moduleHandler,
) {
}
@@ -457,7 +461,7 @@ public function handleDirectoryExists(array &$form, FormStateInterface $form_sta
*/
public function handleShowSession(array &$form, FormStateInterface $form_state) {
$dumper = $this->dumper();
if ($dumper instanceof DevelDumperInterface) {
if ($this->isDevelDumper($dumper)) {
// If the devel module is installed, use its nicer message format.
$dumper->dump($this->sessionHelperWrapper->getStoredData(), $this->t('Entire $_SESSION["file_example"]'));
}
@@ -484,4 +488,22 @@ public function handleResetSession(array &$form, FormStateInterface $form_state)
$this->messenger->addMessage('Session reset.');
}
/**
* Checks if the given object is an instance of DevelDumperInterface.
*
* @param object $object
* The object to check.
*
* @return bool
* Returns TRUE if the object is an instance of DevelDumperInterface,
* FALSE otherwise.
*/
protected function isDevelDumper(object $object): bool {
if ($this->moduleHandler->moduleExists('devel')) {
return $object instanceof DevelDumperInterface;
}
return FALSE;
}
}
Loading