diff --git a/src/Hook/WeightHooks.php b/src/Hook/WeightHooks.php
new file mode 100644
index 0000000..8097339
--- /dev/null
+++ b/src/Hook/WeightHooks.php
@@ -0,0 +1,89 @@
+<?php
+
+namespace Drupal\weight\Hook;
+
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+
+/**
+ * Hook implementations for weight.
+ */
+class WeightHooks {
+  use StringTranslationTrait;
+
+  /**
+   * Implements hook_help().
+   */
+  #[Hook('help')]
+  public function help($route_name, RouteMatchInterface $route_match) {
+    switch ($route_name) {
+      case 'help.page.weight':
+        $output = '';
+        $output .= '<h3>' . $this->t('About') . '</h3>';
+        $output .= '<p>' . $this->t('This module provides a weight field that can be added to any fieldable entity.') . '</p>';
+        $output .= '<p>' . $this->t('The weight field can be used to provide customized sorting.') . '</p>';
+        $output .= '<h3>' . $this->t('How to use') . '</h3>';
+        $output .= '<p>' . $this->t('Now the weight field is available to be used in any entity. So just as example, you can add the "weight" field in a content type:') . '</p>';
+        $output .= '<ul>';
+        $output .= '<li>' . $this->t('Access: "Structure" » "Content types" » <CONTENT-TYPE> » "Manage fields"') . '</li>';
+        $output .= '<li>' . $this->t('Go to "Add field" and select "General" » "Weight"') . '</li>';
+        $output .= '<li>' . $this->t('Put a label and save.') . '</li>';
+        $output .= '<li>' . $this->t('Now you can select a "Range" value that will be range of weights available to select. For example, a range of 20 will allow you to select a weight between -20 and 20.') . '</li>';
+        $output .= '<li>' . $this->t('Save.') . '</li>';
+        $output .= '<li>' . $this->t('Now you can add a node using this content type:') . '</li>';
+        $output .= '<li>' . $this->t('Go to "Content" » "Add content" » <CONTENT-TYPE>') . '</li>';
+        $output .= '<li>' . $this->t('Now you can see the "weight" and the range to select') . '</li>';
+        $output .= '</ul>';
+        return $output;
+
+      default:
+    }
+  }
+
+  /**
+   * Implements hook_preprocess_views_view_table().
+   */
+  #[Hook('preprocess_views_view_table')]
+  public static function preprocessViewsViewTable(&$variables) {
+    // Check if view return results.
+    if (!$variables['result']) {
+      return;
+    }
+    // Check for a weight selector field.
+    foreach ($variables['view']->field as $field_key => $field) {
+      if (isset($field->options['plugin_id']) && $field->options['plugin_id'] == 'weight_selector') {
+        // Check if the weight selector is on the first column.
+        $is_first_column = array_search($field_key, array_keys($variables['view']->field)) > 0 ? FALSE : TRUE;
+        // Add the tabledrag attributes.
+        foreach ($variables['rows'] as $key => $row) {
+          if ($is_first_column) {
+            // If the weight selector is the first column move it to the last
+            // column, in order to make the draggable widget appear.
+            $weight_selector = $variables['rows'][$key]['columns'][$field->field];
+            unset($variables['rows'][$key]['columns'][$field->field]);
+            $variables['rows'][$key]['columns'][$field->field] = $weight_selector;
+            $header_weight_selector = $variables['header'][$field->field];
+            unset($variables['header'][$field->field]);
+            $variables['header'][$field->field] = $header_weight_selector;
+          }
+          // Add draggable attribute.
+          $variables['rows'][$key]['attributes']->addClass('draggable');
+        }
+        // The row key identify in an unique way a view grouped by a field.
+        // Without row number, all the groups will share the same table_id
+        // and just the first table can be draggable.
+        $table_id = 'weight-table-' . $variables['view']->dom_id . '-row-' . $key;
+        $variables['attributes']['id'] = $table_id;
+        $options = [
+          'table_id' => $table_id,
+          'action' => 'order',
+          'relationship' => 'sibling',
+          'group' => 'weight-selector',
+        ];
+        drupal_attach_tabledrag($variables, $options);
+      }
+    }
+  }
+
+}
diff --git a/src/Hook/WeightViewsHooks.php b/src/Hook/WeightViewsHooks.php
new file mode 100644
index 0000000..aebef3a
--- /dev/null
+++ b/src/Hook/WeightViewsHooks.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Drupal\weight\Hook;
+
+use Drupal\Component\Utility\DeprecationHelper;
+use Drupal\field\FieldStorageConfigInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+
+/**
+ * Hook implementations for weight.
+ */
+class WeightViewsHooks {
+  use StringTranslationTrait;
+
+  /**
+   * Implements hook_field_views_data().
+   */
+  #[Hook('field_views_data')]
+  public function fieldViewsData(FieldStorageConfigInterface $field_storage) {
+    $data = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.2.0', fn() => \Drupal::service('views.field_data_provider')->defaultFieldImplementation($field_storage), fn() => views_field_default_views_data($field_storage));
+    $field_name = $field_storage->getName();
+    foreach ($data as &$table_data) {
+      if (isset($table_data[$field_name])) {
+        $table_data[$field_name . '_value']['field'] = $table_data[$field_name]['field'];
+        $title = $this->t('@title Selector (@field)', [
+          '@title' => $table_data[$field_name]['title'],
+          '@field' => $field_name,
+        ]);
+        $short_title = $this->t('@title Selector', [
+          '@title' => $table_data[$field_name]['title'],
+        ]);
+        $table_data[$field_name]['title'] = $title;
+        $table_data[$field_name]['title short'] = $short_title;
+        $table_data[$field_name]['field']['id'] = 'weight_selector';
+      }
+    }
+    return $data;
+  }
+
+}
diff --git a/tests/src/FunctionalJavascript/WeightTest.php b/tests/src/FunctionalJavascript/WeightTest.php
index dbb2aa3..f4feffa 100644
--- a/tests/src/FunctionalJavascript/WeightTest.php
+++ b/tests/src/FunctionalJavascript/WeightTest.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\Tests\weight\FunctionalJavascript;
 
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
 use Behat\Mink\Exception\ExpectationException;
 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
@@ -15,6 +17,8 @@ use Drupal\views\Tests\ViewTestData;
  *
  * @group weight
  */
+#[Group('weight')]
+#[RunTestsInSeparateProcesses]
 class WeightTest extends WebDriverTestBase {
 
   use FieldUiTestTrait;
diff --git a/weight.module b/weight.module
index 337bb0b..0f15b28 100644
--- a/weight.module
+++ b/weight.module
@@ -5,82 +5,22 @@
  * Defines weight field types.
  */
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\weight\Hook\WeightHooks;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function weight_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    case 'help.page.weight':
-      $output = '';
-      $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('This module provides a weight field that can be added to any fieldable entity.') . '</p>';
-      $output .= '<p>' . t('The weight field can be used to provide customized sorting.') . '</p>';
-      $output .= '<h3>' . t('How to use') . '</h3>';
-      $output .= '<p>' . t('Now the weight field is available to be used in any entity. So just as example, you can add the "weight" field in a content type:') . '</p>';
-      $output .= '<ul>';
-      $output .= '<li>' . t('Access: "Structure" » "Content types" » <CONTENT-TYPE> » "Manage fields"') . '</li>';
-      $output .= '<li>' . t('Go to "Add field" and select "General" » "Weight"') . '</li>';
-      $output .= '<li>' . t('Put a label and save.') . '</li>';
-      $output .= '<li>' . t('Now you can select a "Range" value that will be range of weights available to select. For example, a range of 20 will allow you to select a weight between -20 and 20.') . '</li>';
-      $output .= '<li>' . t('Save.') . '</li>';
-      $output .= '<li>' . t('Now you can add a node using this content type:') . '</li>';
-      $output .= '<li>' . t('Go to "Content" » "Add content" » <CONTENT-TYPE>') . '</li>';
-      $output .= '<li>' . t('Now you can see the "weight" and the range to select') . '</li>';
-      $output .= '</ul>';
-      return $output;
-
-    default:
-  }
+  return \Drupal::service(WeightHooks::class)->help($route_name, $route_match);
 }
 
 /**
  * Implements hook_preprocess_views_view_table().
  */
+#[LegacyHook]
 function weight_preprocess_views_view_table(&$variables) {
-
-  // Check if view return results.
-  if (!$variables['result']) {
-    return;
-  }
-
-  // Check for a weight selector field.
-  foreach ($variables['view']->field as $field_key => $field) {
-    if (isset($field->options['plugin_id']) && $field->options['plugin_id'] == 'weight_selector') {
-
-      // Check if the weight selector is on the first column.
-      $is_first_column = array_search($field_key, array_keys($variables['view']->field)) > 0 ? FALSE : TRUE;
-
-      // Add the tabledrag attributes.
-      foreach ($variables['rows'] as $key => $row) {
-        if ($is_first_column) {
-          // If the weight selector is the first column move it to the last
-          // column, in order to make the draggable widget appear.
-          $weight_selector = $variables['rows'][$key]['columns'][$field->field];
-          unset($variables['rows'][$key]['columns'][$field->field]);
-          $variables['rows'][$key]['columns'][$field->field] = $weight_selector;
-
-          $header_weight_selector = $variables['header'][$field->field];
-          unset($variables['header'][$field->field]);
-          $variables['header'][$field->field] = $header_weight_selector;
-        }
-        // Add draggable attribute.
-        $variables['rows'][$key]['attributes']->addClass('draggable');
-      }
-      // The row key identify in an unique way a view grouped by a field.
-      // Without row number, all the groups will share the same table_id
-      // and just the first table can be draggable.
-      $table_id = 'weight-table-' . $variables['view']->dom_id . '-row-' . $key;
-      $variables['attributes']['id'] = $table_id;
-
-      $options = [
-        'table_id' => $table_id,
-        'action' => 'order',
-        'relationship' => 'sibling',
-        'group' => 'weight-selector',
-      ];
-      drupal_attach_tabledrag($variables, $options);
-    }
-  }
+  \Drupal::service(WeightHooks::class)->preprocessViewsViewTable($variables);
 }
diff --git a/weight.services.yml b/weight.services.yml
new file mode 100644
index 0000000..b091960
--- /dev/null
+++ b/weight.services.yml
@@ -0,0 +1,9 @@
+
+services:
+  Drupal\weight\Hook\WeightHooks:
+    class: Drupal\weight\Hook\WeightHooks
+    autowire: true
+
+  Drupal\weight\Hook\WeightViewsHooks:
+    class: Drupal\weight\Hook\WeightViewsHooks
+    autowire: true
diff --git a/weight.views.inc b/weight.views.inc
index d6993fd..3db38d8 100644
--- a/weight.views.inc
+++ b/weight.views.inc
@@ -5,28 +5,14 @@
  * Provide Views data for weight fields.
  */
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\weight\Hook\WeightViewsHooks;
 use Drupal\field\FieldStorageConfigInterface;
 
 /**
  * Implements hook_field_views_data().
  */
+#[LegacyHook]
 function weight_field_views_data(FieldStorageConfigInterface $field_storage) {
-  $data = views_field_default_views_data($field_storage);
-  $field_name = $field_storage->getName();
-
-  foreach ($data as &$table_data) {
-    if (isset($table_data[$field_name])) {
-      $table_data[$field_name . '_value']['field'] = $table_data[$field_name]['field'];
-      $title = t('@title Selector (@field)', [
-        '@title' => $table_data[$field_name]['title'],
-        '@field' => $field_name,
-      ]);
-      $short_title = t('@title Selector', ['@title' => $table_data[$field_name]['title']]);
-      $table_data[$field_name]['title'] = $title;
-      $table_data[$field_name]['title short'] = $short_title;
-      $table_data[$field_name]['field']['id'] = 'weight_selector';
-    }
-  }
-
-  return $data;
+  return \Drupal::service(WeightViewsHooks::class)->fieldViewsData($field_storage);
 }
