Skip to content

Instantly share code, notes, and snippets.

@jonhattan
Created September 30, 2014 07:56
Show Gist options
  • Save jonhattan/84f52cfeb06868cc6ade to your computer and use it in GitHub Desktop.
Save jonhattan/84f52cfeb06868cc6ade to your computer and use it in GitHub Desktop.
Ref: https://www.drupal.org/node/2208949 (D8 strategy for Drush)
diff --git a/core/rebuild.php b/core/rebuild.php
index c915aff..f26eb6f 100644
--- a/core/rebuild.php
+++ b/core/rebuild.php
@@ -15,6 +15,9 @@
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\KernelEvents;
+
// Change the directory to the Drupal root.
chdir('..');
@@ -22,10 +25,15 @@
require_once __DIR__ . '/includes/utility.inc';
$request = Request::createFromGlobals();
-// Manually resemble early bootstrap of DrupalKernel::boot().
-require_once __DIR__ . '/includes/bootstrap.inc';
-DrupalKernel::bootEnvironment();
-Settings::initialize(DrupalKernel::findSitePath($request), $autoloader);
+
+$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
+$kernel->boot();
+
+\Drupal::requestStack()->push($request);
+
+$httpkernel = \Drupal::service('http_kernel');
+$event = new GetResponseEvent($httpkernel, $request, $kernel::MASTER_REQUEST);
+\Drupal::service('event_dispatcher')->dispatch(KernelEvents::REQUEST, $event);
if (Settings::get('rebuild_access', FALSE) ||
($request->get('token') && $request->get('timestamp') &&
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment