keep support for drupal 8
authordemeritcowboy <demeritcowboy@hotmail.com>
Tue, 26 Apr 2022 13:20:49 +0000 (09:20 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Tue, 26 Apr 2022 13:21:36 +0000 (09:21 -0400)
CRM/Utils/System/Drupal8.php

index 9793f30d79c284823b77eec249ec892c1fcc8818..61ded6086528d956bc20b1c45036be37cd20d692 100644 (file)
@@ -419,8 +419,11 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
     $kernel->preHandle($request);
     $container = $kernel->rebuildContainer();
     // Add our request to the stack and route context.
-    $request->attributes->set(\Drupal\Core\Routing\RouteObjectInterface::ROUTE_OBJECT, new \Symfony\Component\Routing\Route('<none>'));
-    $request->attributes->set(\Drupal\Core\Routing\RouteObjectInterface::ROUTE_NAME, '<none>');
+    $routeInterface = class_exists('\Drupal\Core\Routing\RouteObjectInterface')
+      ? '\Drupal\Core\Routing\RouteObjectInterface'
+      : '\Symfony\Cmf\Component\Routing\RouteObjectInterface';
+    $request->attributes->set($routeInterface::ROUTE_OBJECT, new \Symfony\Component\Routing\Route('<none>'));
+    $request->attributes->set($routeInterface::ROUTE_NAME, '<none>');
     $container->get('request_stack')->push($request);
     $container->get('router.request_context')->fromRequest($request);