From c565310af173cb50d9d683373bd44915d524eb94 Mon Sep 17 00:00:00 2001
From: Mark Carver <mark.carver@me.com>
Date: Thu, 22 Feb 2018 22:59:03 -0600
Subject: [PATCH] Issue #2608500 by jsst, markcarver: Allow usage of
 alternative autoloaders

Signed-off-by: Mark Carver <mark.carver@me.com>
---
 service_container.info    | 11 ++++++++---
 service_container.install | 27 +++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/service_container.info b/service_container.info
index f4d343e..901b14f 100644
--- a/service_container.info
+++ b/service_container.info
@@ -2,11 +2,16 @@ name = Service Container
 description = A light-weight service container based on CTools plugins.
 package = Utility
 core = 7.x
-php = 5.3.10
+php = 5.6
 
-; Dependencies
+; Hard dependencies.
+dependencies[] = any
 dependencies[] = ctools
-dependencies[] = registry_autoload
+
+; Require one of the following autoload contrib dependencies.
+any[autoload][] = registry_autoload (>= 7.x-1.3)
+any[autoload][] = xautoload (>= 7.x-5.0)
+any[autoload][] = autoload
 
 registry_autoload[] = PSR-0
 registry_autoload[] = PSR-4
diff --git a/service_container.install b/service_container.install
index 9d4fe49..da52857 100644
--- a/service_container.install
+++ b/service_container.install
@@ -8,6 +8,33 @@
  * - key_value_expire
  */
 
+/**
+ * Implements hook_requirements().
+ */
+function service_container_requirements($phase) {
+  // Attempt to load the "any" dependencies module.
+  if (!module_exists('any')) {
+    module_enable(['any']);
+  }
+
+  // If "any" still doesn't exist then inform the user.
+  if (!module_exists('any')) {
+    $t = get_t();
+    $requirements["service_container-missing-any"] = [
+      'title' => $t('Missing "any" dependency'),
+      'description' => $t('The module "service_container" requires the !url project. Please download and install it first.', [
+        '!url' => 'https://www.drupal.org/project/any',
+      ]),
+      'severity' => REQUIREMENT_ERROR,
+    ];
+    return $requirements;
+  }
+
+  // Load the "any" module and let it perform requirement checks.
+  drupal_load('module', 'any');
+  return any_check_install_requirements($phase, 'service_container');
+}
+
 /**
  * Implements hook_schema().
  */
-- 
2.15.1

