diff --git a/src/Hook/YamlEditorHooks.php b/src/Hook/YamlEditorHooks.php
new file mode 100644
index 0000000..79a899e
--- /dev/null
+++ b/src/Hook/YamlEditorHooks.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Drupal\yaml_editor\Hook;
+
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for yaml_editor.
+ */
+class YamlEditorHooks
+{
+    /**
+     * Implements hook_page_attachments().
+     */
+    #[Hook('page_attachments')]
+    public function pageAttachments(array &$attachments)
+    {
+        $route = \Drupal::routeMatch()->getRouteObject();
+        $is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);
+        $config = \Drupal::config('yaml_editor.config');
+        $source = $config->get('editor_source');
+        $theme = $config->get('editor_theme');
+        if ($is_admin) {
+            $source = \Drupal::config('yaml_editor.config')->get('editor_source');
+            $attachments['#attached']['drupalSettings']['yamlEditor']['source'] = $source;
+            $attachments['#attached']['drupalSettings']['yamlEditor']['theme'] = $theme;
+            $attachments['#attached']['library'][] = 'yaml_editor/yaml_editor';
+        }
+    }
+}
diff --git a/yaml_editor.info.yml b/yaml_editor.info.yml
index 5d1d4f2..8311aec 100644
--- a/yaml_editor.info.yml
+++ b/yaml_editor.info.yml
@@ -1,6 +1,6 @@
 name: YAML Editor
 type: module
 description: 'Adds an editor for YAML configuration textareas.'
-core_version_requirement: ^8 || ^9 || ^10 || ^11
+core_version_requirement: ^10.1 || ^11 || ^12
 package: Development
 configure: yaml_editor.config
diff --git a/yaml_editor.install b/yaml_editor.install
index 3be6d5e..5894ebe 100644
--- a/yaml_editor.install
+++ b/yaml_editor.install
@@ -6,6 +6,5 @@
 function yaml_editor_update_8001() {
   \Drupal::configFactory()
     ->getEditable('yaml_editor.config')
-    ->set('editor_theme', 'ace/theme/chrome')
-    ->save(TRUE);
+    ->set('editor_theme', 'ace/theme/chrome')->save();
 }
diff --git a/yaml_editor.module b/yaml_editor.module
index 72cec5c..37b084d 100644
--- a/yaml_editor.module
+++ b/yaml_editor.module
@@ -1,20 +1,13 @@
 <?php
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\yaml_editor\Hook\YamlEditorHooks;
+
 /**
  * Implements hook_page_attachments().
  */
-function yaml_editor_page_attachments(array &$attachments) {
-  $route = \Drupal::routeMatch()->getRouteObject();
-  $is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);
-  $config = \Drupal::config('yaml_editor.config');
-  $source = $config->get('editor_source');
-  $theme = $config->get('editor_theme');
-
-  if ($is_admin) {
-    $source = \Drupal::config('yaml_editor.config')->get('editor_source');
-
-    $attachments['#attached']['drupalSettings']['yamlEditor']['source'] = $source;
-    $attachments['#attached']['drupalSettings']['yamlEditor']['theme'] = $theme;
-    $attachments['#attached']['library'][] = 'yaml_editor/yaml_editor';
-  }
+#[LegacyHook]
+function yaml_editor_page_attachments(array &$attachments)
+{
+    \Drupal::service(YamlEditorHooks::class)->pageAttachments($attachments);
 }
diff --git a/yaml_editor.services.yml b/yaml_editor.services.yml
new file mode 100644
index 0000000..3cf5be7
--- /dev/null
+++ b/yaml_editor.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\yaml_editor\Hook\YamlEditorHooks:
+    class: Drupal\yaml_editor\Hook\YamlEditorHooks
+    autowire: true
