[REF] Remove deprecated methods of booting drupal container and getting drupal timezo...
authorSeamus Lee <seamuslee001@gmail.com>
Sat, 6 Jun 2020 09:49:22 +0000 (19:49 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Sat, 6 Jun 2020 09:49:22 +0000 (19:49 +1000)
CRM/Utils/System/Drupal8.php

index 6e42f703b8814c1f36bd5ecf6372bcea2ff57ae9..afb39b811630609e44dca344c595067d5a4f2cf2 100644 (file)
@@ -408,7 +408,15 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
     $request = new \Symfony\Component\HttpFoundation\Request([], [], [], [], [], $_SERVER);
 
     // Create a kernel and boot it.
-    \Drupal\Core\DrupalKernel::createFromRequest($request, $autoloader, 'prod')->prepareLegacyRequest($request);
+    $kernel = \Drupal\Core\DrupalKernel::createFromRequest($request, $autoloader, 'prod');
+    $kernel->boot();
+    $kernel->preHandle($request);
+    $container = $kernel->rebuildContainer();
+    // Add our request to the stack and route context.
+    $request->attributes->set(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT, new \Symfony\Component\Routing\Route('<none>'));
+    $request->attributes->set(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_NAME, '<none>');
+    $container->get('request_stack')->push($request);
+    $container->get('router.request_context')->fromRequest($request);
 
     // Initialize Civicrm
     \Drupal::service('civicrm')->initialize();
@@ -706,7 +714,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
    * @inheritDoc
    */
   public function getTimeZoneString() {
-    $timezone = drupal_get_user_timezone();
+    $timezone = date_default_timezone_get();
     return $timezone;
   }