本文整理汇总了PHP中Drupal\Core\DrupalKernel::bootEnvironment方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalKernel::bootEnvironment方法的具体用法?PHP DrupalKernel::bootEnvironment怎么用?PHP DrupalKernel::bootEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\DrupalKernel
的用法示例。
在下文中一共展示了DrupalKernel::bootEnvironment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getApplication
/**
* Create a Drupal application.
*/
public function getApplication()
{
// Bootstrap Drupal.
// Bootstrap code is modeled on a few examples in core/scripts, such as
// db-tools.php.
// Assume we're in DRUPAL_ROOT/vendor/php-pm/httpkernel-adapter/Bootstraps.
// There may be a safer way to do this...
$drupal_root = dirname(dirname(dirname(dirname(__DIR__))));
// @todo: Is it necessary to call bootEnv()? It's called automatically by createFromRequest().
DrupalKernel::bootEnvironment();
$request = Request::createFromGlobals();
// @todo: Is it necessary to call initialize()? Is it called through createFromRequest()?
$autoloader = (include $drupal_root . '/autoload.php');
Settings::initialize($drupal_root, DrupalKernel::findSitePath($request), $autoloader);
$app = DrupalKernel::createFromRequest($request, $autoloader, $this->appenv);
$app->boot();
return $app;
}
示例2: dirname
<?php
/**
* @file
* Rebuilds all Drupal caches even when Drupal itself does not work.
*
* Needs a token query argument which can be calculated using the
* scripts/rebuild_token_calculator.sh script.
*
* @see drupal_rebuild()
*/
use Drupal\Component\Utility\Crypt;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
// Change the directory to the Drupal root.
chdir('..');
$autoloader = (require_once __DIR__ . '/vendor/autoload.php');
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));
if (Settings::get('rebuild_access', FALSE) || $request->get('token') && $request->get('timestamp') && REQUEST_TIME - $request->get('timestamp') < 300 && $request->get('token') === Crypt::hmacBase64($request->get('timestamp'), Settings::get('hash_salt'))) {
drupal_rebuild($autoloader, $request);
drupal_set_message('Cache rebuild complete.');
}
$base_path = dirname(dirname($request->getBaseUrl()));
header('Location: ' . $base_path);