diff --git a/conditional_fields.module b/conditional_fields.module
index 8513aa5..465af87 100644
--- a/conditional_fields.module
+++ b/conditional_fields.module
@@ -5,61 +5,36 @@
  * Contains conditional_fields.module.
  */
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\conditional_fields\Hook\ConditionalFieldsHooks;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\WidgetInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
-use Drupal\Core\Url;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function conditional_fields_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    // Main module help for the conditional_fields module.
-    case 'help.page.conditional_fields':
-      $output = '';
-      $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('Define dependencies between fields based on their states and values.') . '</p>';
-      return $output;
-
-    default:
-  }
+  return \Drupal::service(ConditionalFieldsHooks::class)->help($route_name, $route_match);
 }
 
 /**
  * Implements hook_theme().
  */
+#[LegacyHook]
 function conditional_fields_theme() {
-  $theme = [];
-  $theme['conditional_field'] = [
-    'render element' => 'elements',
-    'file' => 'conditional_field.page.inc',
-    'template' => 'conditional_field',
-  ];
-  $theme['conditional_field_content_add_list'] = [
-    'render element' => 'content',
-    'variables' => ['content' => NULL],
-    'file' => 'conditional_field.page.inc',
-  ];
-  return $theme;
+  return \Drupal::service(ConditionalFieldsHooks::class)->theme();
 }
 
 /**
  * Implements hook_entity_operation().
  */
+#[LegacyHook]
 function conditional_fields_entity_operation(EntityInterface $entity) {
-  $operations = [];
-  $url = Url::fromRoute('conditional_fields.tab.node', [$entity->getEntityTypeId() => $entity->id()]);
-  if ($entity->getEntityTypeId() == 'node_type' && $url->access()) {
-    $operations['dependencies'] = [
-      'title' => t('Manage dependencies'),
-      'url' => $url,
-      'weight' => 29,
-    ];
-  }
-  return $operations;
+  return \Drupal::service(ConditionalFieldsHooks::class)->entityOperation($entity);
 }
 
 /**
@@ -67,10 +42,9 @@ function conditional_fields_entity_operation(EntityInterface $entity) {
  *
  * @see conditional_fields_element_after_build()
  */
+#[LegacyHook]
 function conditional_fields_element_info_alter(array &$types) {
-  foreach ($types as $type => $info) {
-    $types[$type]['#after_build'][] = 'conditional_fields_element_after_build';
-  }
+  \Drupal::service(ConditionalFieldsHooks::class)->elementInfoAlter($types);
 }
 
 /**
@@ -78,21 +52,17 @@ function conditional_fields_element_info_alter(array &$types) {
  *
  * We implement this on behalf of the core Field module.
  */
+#[LegacyHook]
 function conditional_fields_conditional_fields($entity_type, $bundle_name) {
-  $fields = [];
-  $instances = \Drupal::getContainer()->get("entity_field.manager")
-    ->getFieldDefinitions($entity_type, $bundle_name);
-  foreach ($instances as $field) {
-    $fields[$field->getName()] = $field->getLabel();
-  }
-  return $fields;
+  return \Drupal::service(ConditionalFieldsHooks::class)->conditionalFields($entity_type, $bundle_name);
 }
 
 /**
  * Implements hook_conditional_fields_alter().
  */
+#[LegacyHook]
 function conditional_fields_conditional_fields_alter(&$fields, $entity_type, $bundle_name) {
-  asort($fields);
+  \Drupal::service(ConditionalFieldsHooks::class)->conditionalFieldsAlter($fields, $entity_type, $bundle_name);
 }
 
 /**
@@ -140,19 +110,9 @@ function conditional_fields_field_selector($field) {
  * If the field has conditional fields, then ensure they are added on the form
  * display widget settings page so they are not lost.
  */
+#[LegacyHook]
 function conditional_fields_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
-  $element = [];
-  $settings = $plugin->getThirdPartySettings('conditional_fields');
-
-  if (!empty($settings)) {
-    foreach ($settings as $uuid => $setting) {
-      $element[$uuid] = [
-        '#type' => 'value',
-        '#value' => $setting,
-      ];
-    }
-  }
-  return $element;
+  return \Drupal::service(ConditionalFieldsHooks::class)->fieldWidgetThirdPartySettingsForm($plugin, $field_definition, $form_mode, $form, $form_state);
 }
 
 /**
@@ -160,8 +120,9 @@ function conditional_fields_field_widget_third_party_settings_form(WidgetInterfa
  *
  * Hook_form_alter() that attaches an 'afterbuild' function to the form.
  */
+#[LegacyHook]
 function conditional_fields_form_alter(&$form, &$form_state, $form_id) {
-  $form['#after_build'][] = 'conditional_fields_form_after_build';
+  \Drupal::service(ConditionalFieldsHooks::class)->formAlter($form, $form_state, $form_id);
 }
 
 /**
@@ -170,8 +131,9 @@ function conditional_fields_form_alter(&$form, &$form_state, $form_id) {
  * Hook_inline_entity_form_entity_form_alter() that attaches an 'afterbuild'
  * function to the form.
  */
+#[LegacyHook]
 function conditional_fields_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) {
-  $entity_form['#after_build'][] = 'conditional_fields_form_after_build';
+  \Drupal::service(ConditionalFieldsHooks::class)->inlineEntityFormEntityFormAlter($entity_form, $form_state);
 }
 
 /**
@@ -180,8 +142,9 @@ function conditional_fields_inline_entity_form_entity_form_alter(&$entity_form,
  * Runs the 'afterbuild' validation of a form with dependencies.
  * This function will run only once per form.
  */
+#[LegacyHook]
 function conditional_fields_form_after_build($form, &$form_state) {
-  return \Drupal::service('conditional_fields.form_helper')->afterBuild($form, $form_state);
+  return \Drupal::service(ConditionalFieldsHooks::class)->formAfterBuild($form, $form_state);
 }
 
 /**
diff --git a/conditional_fields.services.yml b/conditional_fields.services.yml
index 86fe65f..7aeb1c9 100644
--- a/conditional_fields.services.yml
+++ b/conditional_fields.services.yml
@@ -24,3 +24,7 @@ services:
     arguments:
       - '@module_handler'
       - '@entity_type.manager'
+
+  Drupal\conditional_fields\Hook\ConditionalFieldsHooks:
+    class: Drupal\conditional_fields\Hook\ConditionalFieldsHooks
+    autowire: true
diff --git a/src/Form/ConditionalFieldEditForm.php b/src/Form/ConditionalFieldEditForm.php
index 64d7210..6789b82 100644
--- a/src/Form/ConditionalFieldEditForm.php
+++ b/src/Form/ConditionalFieldEditForm.php
@@ -565,7 +565,7 @@ class ConditionalFieldEditForm extends FormBase {
       }
       else {
         // @phpstan-ignore-next-line
-        watchdog_exception('conditional_fields', $e);
+        Error::logException(\Drupal::logger('conditional_fields'), $e);
       }
       // @todo May be it make sense to return markup?
       return NULL;
diff --git a/src/Hook/ConditionalFieldsHooks.php b/src/Hook/ConditionalFieldsHooks.php
new file mode 100644
index 0000000..de2c590
--- /dev/null
+++ b/src/Hook/ConditionalFieldsHooks.php
@@ -0,0 +1,165 @@
+<?php
+
+namespace Drupal\conditional_fields\Hook;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\WidgetInterface;
+use Drupal\Core\Url;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+
+/**
+ * Hook implementations for conditional_fields.
+ */
+class ConditionalFieldsHooks {
+  use StringTranslationTrait;
+
+  /**
+   * Implements hook_help().
+   */
+  #[Hook('help')]
+  public function help($route_name, RouteMatchInterface $route_match) {
+    switch ($route_name) {
+      // Main module help for the conditional_fields module.
+      case 'help.page.conditional_fields':
+        $output = '';
+        $output .= '<h3>' . $this->t('About') . '</h3>';
+        $output .= '<p>' . $this->t('Define dependencies between fields based on their states and values.') . '</p>';
+        return $output;
+
+      default:
+    }
+  }
+
+  /**
+   * Implements hook_theme().
+   */
+  #[Hook('theme')]
+  public static function theme() {
+    $theme = [];
+    $theme['conditional_field'] = [
+      'render element' => 'elements',
+      'file' => 'conditional_field.page.inc',
+      'template' => 'conditional_field',
+    ];
+    $theme['conditional_field_content_add_list'] = [
+      'render element' => 'content',
+      'variables' => [
+        'content' => NULL,
+      ],
+      'file' => 'conditional_field.page.inc',
+    ];
+    return $theme;
+  }
+
+  /**
+   * Implements hook_entity_operation().
+   */
+  #[Hook('entity_operation')]
+  public function entityOperation(EntityInterface $entity) {
+    $operations = [];
+    $url = Url::fromRoute('conditional_fields.tab.node', [
+      $entity->getEntityTypeId() => $entity->id(),
+    ]);
+    if ($entity->getEntityTypeId() == 'node_type' && $url->access()) {
+      $operations['dependencies'] = [
+        'title' => $this->t('Manage dependencies'),
+        'url' => $url,
+        'weight' => 29,
+      ];
+    }
+    return $operations;
+  }
+
+  /**
+   * Implements hook_element_info_alter().
+   *
+   * @see conditional_fields_element_after_build()
+   */
+  #[Hook('element_info_alter')]
+  public static function elementInfoAlter(array &$types) {
+    foreach ($types as $type => $info) {
+      $types[$type]['#after_build'][] = 'conditional_fields_element_after_build';
+    }
+  }
+
+  /**
+   * Implements hook_conditional_fields().
+   *
+   * We implement this on behalf of the core Field module.
+   */
+  #[Hook('conditional_fields')]
+  public static function conditionalFields($entity_type, $bundle_name) {
+    $fields = [];
+    $instances = \Drupal::getContainer()->get("entity_field.manager")->getFieldDefinitions($entity_type, $bundle_name);
+    foreach ($instances as $field) {
+      $fields[$field->getName()] = $field->getLabel();
+    }
+    return $fields;
+  }
+
+  /**
+   * Implements hook_conditional_fields_alter().
+   */
+  #[Hook('conditional_fields_alter')]
+  public static function conditionalFieldsAlter(&$fields, $entity_type, $bundle_name) {
+    asort($fields);
+  }
+
+  /**
+   * Implements hook_field_widget_third_party_settings_form().
+   *
+   * If the field has conditional fields, then ensure they are added on the form
+   * display widget settings page so they are not lost.
+   */
+  #[Hook('field_widget_third_party_settings_form')]
+  public static function fieldWidgetThirdPartySettingsForm(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
+    $element = [];
+    $settings = $plugin->getThirdPartySettings('conditional_fields');
+    if (!empty($settings)) {
+      foreach ($settings as $uuid => $setting) {
+        $element[$uuid] = [
+          '#type' => 'value',
+          '#value' => $setting,
+        ];
+      }
+    }
+    return $element;
+  }
+
+  /**
+   * Implements hook_form_alter().
+   *
+   * Hook_form_alter() that attaches an 'afterbuild' function to the form.
+   */
+  #[Hook('form_alter')]
+  public static function formAlter(&$form, &$form_state, $form_id) {
+    $form['#after_build'][] = 'conditional_fields_form_after_build';
+  }
+
+  /**
+   * Implements hook_inline_entity_form_entity_form_alter().
+   *
+   * Hook_inline_entity_form_entity_form_alter() that attaches an 'afterbuild'
+   * function to the form.
+   */
+  #[Hook('inline_entity_form_entity_form_alter')]
+  public static function inlineEntityFormEntityFormAlter(&$entity_form, &$form_state) {
+    $entity_form['#after_build'][] = 'conditional_fields_form_after_build';
+  }
+
+  /**
+   * Implements hook_form_after_build().
+   *
+   * Runs the 'afterbuild' validation of a form with dependencies.
+   * This function will run only once per form.
+   */
+  #[Hook('form_after_build')]
+  public static function formAfterBuild($form, &$form_state) {
+    return \Drupal::service('conditional_fields.form_helper')->afterBuild($form, $form_state);
+  }
+
+}
