diff --git a/src/SectionsCollector.php b/src/SectionsCollector.php
index 2d16465..ae33404 100644
--- a/src/SectionsCollector.php
+++ b/src/SectionsCollector.php
@@ -73,7 +73,7 @@ class SectionsCollector implements SectionsCollectorInterface, EventSubscriberIn
     if (!$directory) {
       $directory = drupal_get_path('module', 'ckeditor5_sections') . '/sections';
     }
-    $files = file_scan_directory($directory, '/.*.css/');
+    $files = \Drupal::service('file_system')->scanDirectory($directory, '/.*.css/');
     $styleSheets = [];
     foreach ($files as $file => $file_info) {
       $styleSheets[] = $file_info->uri;
@@ -107,7 +107,7 @@ class SectionsCollector implements SectionsCollectorInterface, EventSubscriberIn
     if ($directory === '') {
       $directory = drupal_get_path('module', 'ckeditor5_sections') . '/sections';
     }
-    $files = file_scan_directory($directory, '/.*.yml/');
+    $files = \Drupal::service('file_system')->scanDirectory($directory, '/.*.yml/');
     $sections = [];
     foreach ($files as $file => $file_info) {
       $info = Yaml::parseFile($file);
diff --git a/tests/src/Unit/SectionsCollectorTest.php b/tests/src/Unit/SectionsCollectorTest.php
index af3b655..85fb15f 100644
--- a/tests/src/Unit/SectionsCollectorTest.php
+++ b/tests/src/Unit/SectionsCollectorTest.php
@@ -2,6 +2,8 @@
 
 namespace {
 
+  use Drupal\Tests\UnitTestCase;
+  use Drupal\ckeditor5_sections\SectionsCollector;
   if (!function_exists('file_scan_directory')) {
 
     /**
