diff --git a/domain/src/Commands/DomainCommands.php b/domain/src/Commands/DomainCommands.php
index 72403888..8f9bc44a 100644
--- a/domain/src/Commands/DomainCommands.php
+++ b/domain/src/Commands/DomainCommands.php
@@ -6,13 +6,15 @@ use Consolidation\AnnotatedCommand\Events\CustomEventAwareInterface;
 use Consolidation\AnnotatedCommand\Events\CustomEventAwareTrait;
 use Consolidation\OutputFormatters\StructuredData\PropertyList;
 use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
-use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
 use Drupal\Component\Plugin\Exception\PluginException;
-use Drupal\Component\Plugin\Exception\PluginNotFoundException;
 use Drupal\Component\Utility\Html;
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Entity\EntityFieldManagerInterface;
 use Drupal\Core\Entity\EntityStorageException;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
 use Drupal\domain\DomainInterface;
+use Drupal\domain\DomainValidatorInterface;
 use Drush\Commands\DrushCommands;
 use GuzzleHttp\Exception\TransferException;
 
@@ -23,19 +25,47 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
 
   use CustomEventAwareTrait;
 
+  /**
+   * The config factory.
+   *
+   * @var \Drupal\Core\Config\ConfigFactoryInterface
+   */
+  protected $configFactory;
+
   /**
    * The domain entity storage service.
    *
    * @var \Drupal\domain\DomainStorageInterface
    */
-  protected $domainStorage = NULL;
+  protected $domainStorage;
+
+  /**
+   * The domain validator.
+   *
+   * @var \Drupal\domain\DomainValidatorInterface
+   */
+  protected $domainValidator;
+
+  /**
+   * The entity field manager.
+   *
+   * @var \Drupal\Core\Entity\EntityFieldManagerInterface
+   */
+  protected $entityFieldManager;
+
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected $entityTypeManager;
 
   /**
    * Local cache of entity field map, kept for performance.
    *
    * @var array
    */
-  protected $entityFieldMap = NULL;
+  protected $entityFieldMap;
 
   /**
    * Flag set by the --dryrun cli option.
@@ -50,9 +80,53 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    * Static array of special-case policies for reassigning field data.
    *
    * @var string[]
-   * */
+   */
   protected $reassignmentPolicies = ['prompt', 'default', 'ignore'];
 
+  /**
+   * Construct the command object.
+   *
+   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
+   *   The config factory.
+   * @param \Drupal\domain\DomainValidatorInterface $domain_validator
+   *   The domain validator.
+   * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
+   *   The entity field manager.
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity type manager.
+   */
+  public function __construct(ConfigFactoryInterface $config_factory,
+                              DomainValidatorInterface $domain_validator,
+                              EntityFieldManagerInterface $entity_field_manager,
+                              EntityTypeManagerInterface $entity_type_manager,
+  ) {
+    parent::__construct();
+    $this->configFactory = $config_factory;
+    $this->domainValidator = $domain_validator;
+    $this->entityFieldManager = $entity_field_manager;
+    $this->entityTypeManager = $entity_type_manager;
+    $this->domainStorage = $this->entityTypeManager->getStorage('domain');
+    $this->entityFieldMap = $this->entityFieldManager->getFieldMap();
+  }
+
+  /**
+   * Inject services for our commands.
+   *
+   * See https://www.drush.org/12.x/dependency-injection/#create-method
+   *
+   * @param \Psr\Container\ContainerInterface $container
+   *   The service container
+   * @return static
+   */
+  public static function create(Psr\Container\ContainerInterface $container): self {
+    return new static(
+      $container->get('config.factory'),
+      $container->get('domain.validator'),
+      $container->get('entity_field.manager'),
+      $container->get('entity_type.manager')
+    );
+  }
+
   /**
    * List active domains for the site.
    *
@@ -90,7 +164,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    */
   public function listDomains(array $options) {
     // Load all domains:
-    $domains = $this->domainStorage()->loadMultipleSorted();
+    $domains = $this->domainStorage->loadMultipleSorted();
 
     if (count($domains) === 0) {
       $this->logger()->warning(dt('No domains have been created. Use "drush domain:add" to create one.'));
@@ -181,11 +255,11 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    * @throws \Drupal\domain\Commands\DomainCommandException
    */
   public function infoDomains() {
-    $default_domain = $this->domainStorage()->loadDefaultDomain();
+    $default_domain = $this->domainStorage->loadDefaultDomain();
 
     // Load all domains.
     /** @var \Drupal\domain\DomainInterface[] $all_domains */
-    $all_domains = $this->domainStorage()->loadMultiple(NULL);
+    $all_domains = $this->domainStorage->loadMultiple(NULL);
     $active_domains = [];
     foreach ($all_domains as $domain) {
       if ($domain->status()) {
@@ -227,7 +301,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
           break;
 
         case 'scheme':
-          $v = implode(', ', array_keys($this->domainStorage()->loadSchema()));
+          $v = implode(', ', array_keys($this->domainStorage->loadSchema()));
           break;
       }
 
@@ -250,7 +324,6 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    *   A comma-separated list of entities containing a specific field.
    */
   public function getFieldEntities($field_name) {
-    $this->ensureEntityFieldMap();
     $domain_entities = [];
     foreach ($this->entityFieldMap as $type => $fields) {
       if (array_key_exists($field_name, $fields)) {
@@ -323,7 +396,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
       );
     }
 
-    $domains = $this->domainStorage()->loadMultipleSorted();
+    $domains = $this->domainStorage->loadMultipleSorted();
     $start_weight = count($domains) + 1;
     $values = [
       'hostname' => $hostname,
@@ -332,10 +405,10 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
       'scheme' => $options['scheme'] ?? 'http',
       'weight' => $options['weight'] ?? $start_weight,
       'is_default' => $options['is_default'] ?? 0,
-      'id' => $this->domainStorage()->createMachineName($hostname),
+      'id' => $this->domainStorage->createMachineName($hostname),
     ];
     /** @var \Drupal\domain\DomainInterface */
-    $domain = $this->domainStorage()->create($values);
+    $domain = $this->domainStorage->create($values);
 
     // Check for hostname validity. This is required.
     $valid = $this->validateDomain($domain);
@@ -450,7 +523,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
     $this->isDryRun = (bool) $options['dryrun'];
 
     // Get current domain list and perform validation checks.
-    $all_domains = $this->domainStorage()->loadMultipleSorted();
+    $all_domains = $this->domainStorage->loadMultipleSorted();
 
     if (count($all_domains) === 0) {
       throw new DomainCommandException('There are no configured domains.');
@@ -525,8 +598,8 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    */
   public function doReassign(DomainInterface $target_domain, array $delete_options) {
     $policy = $delete_options['policy'];
-    $default_domain = $this->domainStorage()->loadDefaultDomain();
-    $all_domains = $this->domainStorage()->loadMultipleSorted(NULL);
+    $default_domain = $this->domainStorage->loadDefaultDomain();
+    $all_domains = $this->domainStorage->loadMultipleSorted(NULL);
 
     // Perform the 'prompt' for a destination domain.
     if ($policy === 'prompt') {
@@ -595,7 +668,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    */
   public function test($domain_id = NULL) {
     if (is_null($domain_id)) {
-      $domains = $this->domainStorage()->loadMultipleSorted();
+      $domains = $this->domainStorage->loadMultipleSorted();
     }
     else {
       $domain = $this->getDomainFromArgument($domain_id);
@@ -664,7 +737,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
     }
 
     // Now, ask for the current default, so we know if it worked.
-    $domain = $this->domainStorage()->loadDefaultDomain();
+    $domain = $this->domainStorage->loadDefaultDomain();
     if ($domain->status()) {
       $this->logger()->info(dt('!domain set to primary domain.',
         ['!domain' => $domain->getHostname()]));
@@ -903,10 +976,10 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
       $count = 15;
     }
 
-    $domains = $this->domainStorage()->loadMultiple();
+    $domains = $this->domainStorage->loadMultiple();
     if (isset($options['empty']) && $options['empty']) {
-      $this->domainStorage()->delete($domains);
-      $domains = $this->domainStorage()->loadMultiple();
+      $this->domainStorage->delete($domains);
+      $domains = $this->domainStorage->loadMultiple();
     }
     // Ensure we don't duplicate any domains.
     $existing = [];
@@ -970,15 +1043,15 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
     foreach ($prepared as $key => $item) {
       $hostname = mb_strtolower($item);
       $values = [
-        'name' => ($item !== $primary) ? ucwords(str_replace(".$primary", '', $item)) : \Drupal::config('system.site')->get('name'),
+        'name' => ($item !== $primary) ? ucwords(str_replace(".$primary", '', $item)) : $this->configFactory->get('system.site')->get('name'),
         'hostname' => $hostname,
         'scheme' => $options['scheme'],
         'status' => 1,
         'weight' => ($item !== $primary) ? $key + $start_weight + 1 : -1,
         'is_default' => 0,
-        'id' => $this->domainStorage()->createMachineName($hostname),
+        'id' => $this->domainStorage->createMachineName($hostname),
       ];
-      $domain = $this->domainStorage()->create($values);
+      $domain = $this->domainStorage->create($values);
       if ($domain instanceof DomainInterface) {
         $domain->save();
         $list[] = dt('Created @domain.', ['@domain' => $domain->getHostname()]);
@@ -995,35 +1068,6 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
     }
   }
 
-  /**
-   * Gets a domain storage object or throw an exception.
-   *
-   * Note that domain can run very early in the bootstrap, so we cannot
-   * reliably inject this service.
-   *
-   * @return \Drupal\domain\DomainStorageInterface
-   *   The domain storage handler.
-   *
-   * @throws \Drupal\domain\Commands\DomainCommandException
-   */
-  protected function domainStorage() {
-    if (!is_null($this->domainStorage)) {
-      return $this->domainStorage;
-    }
-
-    try {
-      $this->domainStorage = \Drupal::entityTypeManager()->getStorage('domain');
-    }
-    catch (PluginNotFoundException $e) {
-      throw new DomainCommandException('Unable to get domain: no storage', $e);
-    }
-    catch (InvalidPluginDefinitionException $e) {
-      throw new DomainCommandException('Unable to get domain: bad storage', $e);
-    }
-
-    return $this->domainStorage;
-  }
-
   /**
    * Loads a domain based on a string identifier.
    *
@@ -1038,10 +1082,10 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
   protected function getDomainFromArgument($argument) {
 
     // Try loading domain assuming arg is a machine name.
-    $domain = $this->domainStorage()->load($argument);
+    $domain = $this->domainStorage->load($argument);
     if (is_null($domain)) {
       // Try loading assuming it is a host name.
-      $domain = $this->domainStorage()->loadByHostname($argument);
+      $domain = $this->domainStorage->loadByHostname($argument);
     }
 
     // domain_id (an INT) is only used internally because the Node Access
@@ -1155,13 +1199,9 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    *
    * @return int
    *   The server response code for the request.
-   *
-   * @see domain_validate()
    */
   protected function checkDomain(DomainInterface $domain) {
-    /** @var \Drupal\domain\DomainValidatorInterface $validator */
-    $validator = \Drupal::service('domain.validator');
-    return $validator->checkResponse($domain);
+    return $this->domainValidator->checkResponse($domain);
   }
 
   /**
@@ -1172,13 +1212,9 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    *
    * @return string[]
    *   Array of strings indicating issues found.
-   *
-   * @see domain_validate()
    */
   protected function validateDomain(DomainInterface $domain) {
-    /** @var \Drupal\domain\DomainValidatorInterface $validator */
-    $validator = \Drupal::service('domain.validator');
-    return $validator->validate($domain->getHostname());
+    return $this->domainValidator->validate($domain->getHostname());
   }
 
   /**
@@ -1234,7 +1270,6 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    *   List of entity machine names that support domain references.
    */
   protected function findDomainEnabledEntities($using_field = DomainInterface::DOMAIN_ADMIN_FIELD) {
-    $this->ensureEntityFieldMap();
     $entities = [];
     foreach ($this->entityFieldMap as $type => $fields) {
       if (array_key_exists($using_field, $fields)) {
@@ -1256,25 +1291,9 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    *   True if this type of entity has a domain field.
    */
   protected function entityHasDomainField($entity_type, $field = DomainInterface::DOMAIN_ADMIN_FIELD) {
-    // Try to avoid repeated calls to getFieldMap(), assuming it's expensive.
-    $this->ensureEntityFieldMap();
     return array_key_exists($field, $this->entityFieldMap[$entity_type]);
   }
 
-  /**
-   * Ensure the local entity field map has been defined.
-   *
-   * Asking for the entity field map cause a lot of lookup, so we lazily
-   * fetch it and then remember it to avoid repeated checks.
-   */
-  protected function ensureEntityFieldMap() {
-    // Try to avoid repeated calls to getFieldMap() assuming it's expensive.
-    if (is_null($this->entityFieldMap)) {
-      $entity_field_manager = \Drupal::service('entity_field.manager');
-      $this->entityFieldMap = $entity_field_manager->getFieldMap();
-    }
-  }
-
   /**
    * Enumerate entity instances of the supplied type and domain.
    *
@@ -1301,16 +1320,15 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
       );
       return [];
     }
-
-    $efq = \Drupal::entityQuery($entity_type);
+    $query = $this->entityTypeManager->getStorage($entity_type)->getQuery();
     // Don't access check or we wont get all of the possible entities moved.
-    $efq->accessCheck(FALSE);
-    $efq->condition($field, $domain_id, '=');
+    $query->accessCheck(FALSE);
+    $query->condition($field, $domain_id, '=');
     if ($just_count) {
-      $efq->count();
+      $query->count();
     }
 
-    return $efq->execute();
+    return $query->execute();
   }
 
   /**
@@ -1338,7 +1356,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
    * @throws \Drupal\Core\Entity\EntityStorageException
    */
   protected function reassignEntities($entity_type, $field, DomainInterface $old_domain, DomainInterface $new_domain, array $ids) {
-    $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type);
+    $entity_storage = $this->entityTypeManager->getStorage($entity_type);
     $entities = $entity_storage->loadMultiple($ids);
 
     foreach ($entities as $entity) {
@@ -1389,7 +1407,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
     switch ($policy) {
       // Use the Default Domain machine name.
       case 'default':
-        $new_domain = $this->domainStorage()->loadDefaultDomain();
+        $new_domain = $this->domainStorage->loadDefaultDomain();
         break;
 
       // Ask interactively for a Domain machine name.
@@ -1399,7 +1417,7 @@ class DomainCommands extends DrushCommands implements CustomEventAwareInterface
 
       // Use this (specified) Domain machine name.
       default:
-        $new_domain = $this->domainStorage()->load($policy);
+        $new_domain = $this->domainStorage->load($policy);
         break;
     }
 
