bangpound / drupal-bootstrap
1.3.0
2014-12-07 16:29 UTC
This package is auto-updated.
Last update: 2022-02-01 12:30:19 UTC
README
此库旨在以可覆盖的方式替换Drupal 7的Bootstrap。
使用方法
要使用此库,您必须对Drupal 7核心进行一些修补。
在每个前端控制器(index.php
、cron.php
、authorize.php
、install.php
、update.php
和xmlrpc.php
)中,您必须包含Composer自动加载器。
之后
define('DRUPAL_ROOT', getcwd());
添加
require_once DRUPAL_ROOT .'/../vendor/autoload.php';
为了使Drush正常工作,您必须将drushrc.php
添加到sites/all/drush
<?php // Autoloading for Drush from the Drupal root's composer.json and vendor directory. require __DIR__ . '/../../../vendor/autoload.php';
将包含的drupal_bootstrap.patch
应用到您的Drupal根目录。补丁如下。
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 9f37dfc..28566ea 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -2202,11 +2202,26 @@ function drupal_anonymous_user() { * @param boolean $new_phase * A boolean, set to FALSE if calling drupal_bootstrap from inside a * function called from drupal_bootstrap (recursion). + * @param Drupal\Core\BootstrapInterface $object + * Drupal Bootstrap object. * * @return int * The most recently completed phase. */ -function drupal_bootstrap($phase = NULL, $new_phase = TRUE) { +function drupal_bootstrap($phase = NULL, $new_phase = TRUE, \Drupal\Core\BootstrapInterface $object = NULL) { + + /** @var \Drupal\Core\BootstrapInterface $bootstrap */ + static $bootstrap = NULL; + + // On the first call, bootstrap object does not exist yet. + if (!isset($bootstrap)) { + if (!isset($object)) { + // If no bootstrap object is injected, use default bootstrap. + $object = new \Drupal\Core\Bootstrap(); + } + $bootstrap = $object; + } + // Not drupal_static(), because does not depend on any run-time information. static $phases = array( DRUPAL_BOOTSTRAP_CONFIGURATION, @@ -2243,41 +2258,7 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) { $stored_phase = $current_phase; } - switch ($current_phase) { - case DRUPAL_BOOTSTRAP_CONFIGURATION: - _drupal_bootstrap_configuration(); - break; - - case DRUPAL_BOOTSTRAP_PAGE_CACHE: - _drupal_bootstrap_page_cache(); - break; - - case DRUPAL_BOOTSTRAP_DATABASE: - _drupal_bootstrap_database(); - break; - - case DRUPAL_BOOTSTRAP_VARIABLES: - _drupal_bootstrap_variables(); - break; - - case DRUPAL_BOOTSTRAP_SESSION: - require_once DRUPAL_ROOT . '/' . variable_get('session_inc', 'includes/session.inc'); - drupal_session_initialize(); - break; - - case DRUPAL_BOOTSTRAP_PAGE_HEADER: - _drupal_bootstrap_page_header(); - break; - - case DRUPAL_BOOTSTRAP_LANGUAGE: - drupal_language_initialize(); - break; - - case DRUPAL_BOOTSTRAP_FULL: - require_once DRUPAL_ROOT . '/includes/common.inc'; - _drupal_bootstrap_full(); - break; - } + $bootstrap($current_phase); } } return $stored_phase;