本文整理汇总了PHP中Drupal\Core\Site\Settings::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::initialize方法的具体用法?PHP Settings::initialize怎么用?PHP Settings::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Site\Settings
的用法示例。
在下文中一共展示了Settings::initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSystemData
protected function getSystemData()
{
$systemManager = $this->getSystemManager();
$requirements = $systemManager->listRequirements();
$systemData = [];
foreach ($requirements as $key => $requirement) {
if ($requirement['title'] instanceof \Drupal\Core\StringTranslation\TranslatableMarkup) {
$title = $requirement['title']->render();
} else {
$title = $requirement['title'];
}
$systemData['system'][$title] = $requirement['value'];
}
$kernelHelper = $this->getKernelHelper();
$drupal = $this->getDrupalHelper();
Settings::initialize($drupal->getRoot(), 'sites/default', $kernelHelper->getClassLoader());
try {
$hashSalt = Settings::getHashSalt();
} catch (\Exception $e) {
$hashSalt = '';
}
$systemData['system'][$this->trans('commands.site.status.messages.hash_salt')] = $hashSalt;
$systemData['system'][$this->trans('commands.site.status.messages.console')] = $this->getApplication()->getVersion();
return $systemData;
}
示例2: bootTestEnvironment
public function bootTestEnvironment($sitePath)
{
static::bootEnvironment();
$this->setSitePath($sitePath);
$this->loadLegacyIncludes();
Settings::initialize($this->root, $sitePath, $this->classLoader);
$this->boot();
}
示例3: getSystemData
protected function getSystemData()
{
$systemManager = $this->getSystemManager();
$requirements = $systemManager->listRequirements();
$systemData = [];
foreach ($requirements as $key => $requirement) {
$systemData['system'][$requirement['title']] = $requirement['value'];
}
$kernelHelper = $this->getHelper('kernel');
$drupalAutoLoad = $this->getHelperSet()->get('drupal-autoload');
Settings::initialize($drupalAutoLoad->getDrupalRoot(), 'sites/default', $kernelHelper->getClassLoader());
$systemData['system'][$this->trans('commands.site.status.messages.hash_salt')] = Settings::getHashSalt();
$systemData['system'][$this->trans('commands.site.status.messages.console')] = $this->getApplication()->getVersion();
return $systemData;
}
示例4: 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;
}
示例5: setUpSite
/**
* Overrides method.
*
* We have several forms to navigate through.
*/
protected function setUpSite()
{
// Recreate the container so that we can simulate the submission of the
// SyncConfigureForm after the full bootstrap has occurred. Without out this
// drupal_realpath() does not work so uploading files through
// WebTestBase::postForm() is impossible.
$request = Request::createFromGlobals();
$class_loader = (require $this->container->get('app.root') . '/vendor/autoload.php');
Settings::initialize($this->container->get('app.root'), DrupalKernel::findSitePath($request), $class_loader);
foreach ($GLOBALS['config_directories'] as $type => $path) {
$this->configDirectories[$type] = $path;
}
$this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE);
$this->kernel->prepareLegacyRequest($request);
$this->container = $this->kernel->getContainer();
$this->setUpSyncForm();
$this->setUpInstallConfigureForm();
// If we've got to this point the site is installed using the regular
// installation workflow.
$this->isInstalled = TRUE;
}
示例6: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->keyValueFactory = new KeyValueMemoryFactory();
// Back up settings from TestBase::prepareEnvironment().
$settings = Settings::getAll();
// Allow for test-specific overrides.
$directory = DRUPAL_ROOT . '/' . $this->siteDirectory;
$settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml';
$container_yamls = [];
if (file_exists($settings_services_file)) {
// Copy the testing-specific service overrides in place.
$testing_services_file = $directory . '/services.yml';
copy($settings_services_file, $testing_services_file);
$container_yamls[] = $testing_services_file;
}
$settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php';
if (file_exists($settings_testing_file)) {
// Copy the testing-specific settings.php overrides in place.
copy($settings_testing_file, $directory . '/settings.testing.php');
}
if (file_exists($directory . '/settings.testing.php')) {
// Add the name of the testing class to settings.php and include the
// testing specific overrides
$hash_salt = Settings::getHashSalt();
$test_class = get_class($this);
$container_yamls_export = Variable::export($container_yamls);
$php = <<<EOD
<?php
\$settings['hash_salt'] = '{$hash_salt}';
\$settings['container_yamls'] = {$container_yamls_export};
\$test_class = '{$test_class}';
include DRUPAL_ROOT . '/' . \$site_path . '/settings.testing.php';
EOD;
file_put_contents($directory . '/settings.php', $php);
}
// Add this test class as a service provider.
// @todo Remove the indirection; implement ServiceProviderInterface instead.
$GLOBALS['conf']['container_service_providers']['TestServiceProvider'] = 'Drupal\\simpletest\\TestServiceProvider';
// Bootstrap a new kernel.
$class_loader = (require DRUPAL_ROOT . '/autoload.php');
$this->kernel = new DrupalKernel('testing', $class_loader, FALSE);
$request = Request::create('/');
$site_path = DrupalKernel::findSitePath($request);
$this->kernel->setSitePath($site_path);
if (file_exists($directory . '/settings.testing.php')) {
Settings::initialize(DRUPAL_ROOT, $site_path, $class_loader);
}
$this->kernel->boot();
// Ensure database install tasks have been run.
require_once __DIR__ . '/../../../includes/install.inc';
$connection = Database::getConnection();
$errors = db_installer_object($connection->driver())->runTasks();
if (!empty($errors)) {
$this->fail('Failed to run installer database tasks: ' . implode(', ', $errors));
}
// Reboot the kernel because the container might contain a connection to the
// database that has been closed during the database install tasks. This
// prevents any services created during the first boot from having stale
// database connections, for example, \Drupal\Core\Config\DatabaseStorage.
$this->kernel->shutdown();
$this->kernel->boot();
// Save the original site directory path, so that extensions in the
// site-specific directory can still be discovered in the test site
// environment.
// @see \Drupal\Core\Extension\ExtensionDiscovery::scan()
$settings['test_parent_site'] = $this->originalSite;
// Restore and merge settings.
// DrupalKernel::boot() initializes new Settings, and the containerBuild()
// method sets additional settings.
new Settings($settings + Settings::getAll());
// Create and set new configuration directories.
$this->prepareConfigDirectories();
// Set the request scope.
$this->container = $this->kernel->getContainer();
$this->container->get('request_stack')->push($request);
// Re-inject extension file listings into state, unless the key/value
// service was overridden (in which case its storage does not exist yet).
if ($this->container->get('keyvalue') instanceof KeyValueMemoryFactory) {
$this->container->get('state')->set('system.module.files', $this->moduleFiles);
$this->container->get('state')->set('system.theme.files', $this->themeFiles);
}
// Create a minimal core.extension configuration object so that the list of
// enabled modules can be maintained allowing
// \Drupal\Core\Config\ConfigInstaller::installDefaultConfig() to work.
// Write directly to active storage to avoid early instantiation of
// the event dispatcher which can prevent modules from registering events.
\Drupal::service('config.storage')->write('core.extension', array('module' => array(), 'theme' => array()));
// Collect and set a fixed module list.
$class = get_class($this);
$modules = array();
while ($class) {
if (property_exists($class, 'modules')) {
// Only add the modules, if the $modules property was not inherited.
$rp = new \ReflectionProperty($class, 'modules');
if ($rp->class == $class) {
//.........这里部分代码省略.........
示例7: createFromRequest
/**
* Create a DrupalKernel object from a request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request.
* @param $class_loader
* The class loader. Normally Composer's ClassLoader, as included by the
* front controller, but may also be decorated; e.g.,
* \Symfony\Component\ClassLoader\ApcClassLoader.
* @param string $environment
* String indicating the environment, e.g. 'prod' or 'dev'.
* @param bool $allow_dumping
* (optional) FALSE to stop the container from being written to or read
* from disk. Defaults to TRUE.
*
* @return static
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* In case the host name in the request is not trusted.
*/
public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = TRUE)
{
// Include our bootstrap file.
$core_root = dirname(dirname(dirname(__DIR__)));
require_once $core_root . '/includes/bootstrap.inc';
$kernel = new static($environment, $class_loader, $allow_dumping);
// Ensure sane php environment variables..
static::bootEnvironment();
// Get our most basic settings setup.
$site_path = static::findSitePath($request);
$kernel->setSitePath($site_path);
Settings::initialize(dirname($core_root), $site_path, $class_loader);
// Initialize our list of trusted HTTP Host headers to protect against
// header attacks.
$host_patterns = Settings::get('trusted_host_patterns', array());
if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
throw new BadRequestHttpException('The provided host name is not valid for this server.');
}
}
// Redirect the user to the installation script if Drupal has not been
// installed yet (i.e., if no $databases array has been defined in the
// settings.php file) and we are not already installing.
if (!Database::getConnectionInfo() && !drupal_installation_attempted() && PHP_SAPI !== 'cli') {
$response = new RedirectResponse($request->getBasePath() . '/core/install.php');
$response->prepare($request)->send();
}
return $kernel;
}
示例8: initializeSettings
/**
* Locate site path and initialize settings singleton.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* In case the host name in the request is not trusted.
*/
protected function initializeSettings(Request $request)
{
$site_path = static::findSitePath($request);
$this->setSitePath($site_path);
$class_loader_class = get_class($this->classLoader);
Settings::initialize($this->root, $site_path, $this->classLoader);
// Initialize our list of trusted HTTP Host headers to protect against
// header attacks.
$host_patterns = Settings::get('trusted_host_patterns', array());
if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
throw new BadRequestHttpException('The provided host name is not valid for this server.');
}
}
// If the class loader is still the same, possibly upgrade to the APC class
// loader.
if ($class_loader_class == get_class($this->classLoader) && Settings::get('class_loader_auto_detect', TRUE) && function_exists('apcu_fetch')) {
$prefix = Settings::getApcuPrefix('class_loader', $this->root);
$apc_loader = new ApcClassLoader($prefix, $this->classLoader);
$this->classLoader->unregister();
$apc_loader->register();
$this->classLoader = $apc_loader;
}
}
示例9: setUp
/**
* Sets up a Drupal site for running functional and integration tests.
*
* Installs Drupal with the installation profile specified in
* \Drupal\simpletest\WebTestBase::$profile into the prefixed database.
*
* Afterwards, installs any additional modules specified in the static
* \Drupal\simpletest\WebTestBase::$modules property of each class in the
* class hierarchy.
*
* After installation all caches are flushed and several configuration values
* are reset to the values of the parent site executing the test, since the
* default values may be incompatible with the environment in which tests are
* being executed.
*/
protected function setUp()
{
// When running tests through the Simpletest UI (vs. on the command line),
// Simpletest's batch conflicts with the installer's batch. Batch API does
// not support the concept of nested batches (in which the nested is not
// progressive), so we need to temporarily pretend there was no batch.
// Backup the currently running Simpletest batch.
$this->originalBatch = batch_get();
// Define information about the user 1 account.
$this->rootUser = new UserSession(array('uid' => 1, 'name' => 'admin', 'mail' => 'admin@example.com', 'pass_raw' => $this->randomMachineName()));
// The child site derives its session name from the database prefix when
// running web tests.
$this->generateSessionName($this->databasePrefix);
// Reset the static batch to remove Simpletest's batch operations.
$batch =& batch_get();
$batch = array();
// Get parameters for install_drupal() before removing global variables.
$parameters = $this->installParameters();
// Prepare installer settings that are not install_drupal() parameters.
// Copy and prepare an actual settings.php, so as to resemble a regular
// installation.
// Not using File API; a potential error must trigger a PHP warning.
$directory = DRUPAL_ROOT . '/' . $this->siteDirectory;
copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php');
copy(DRUPAL_ROOT . '/sites/default/default.services.yml', $directory . '/services.yml');
// All file system paths are created by System module during installation.
// @see system_requirements()
// @see TestBase::prepareEnvironment()
$settings['settings']['file_public_path'] = (object) array('value' => $this->publicFilesDirectory, 'required' => TRUE);
$settings['settings']['file_private_path'] = (object) array('value' => $this->privateFilesDirectory, 'required' => TRUE);
// Save the original site directory path, so that extensions in the
// site-specific directory can still be discovered in the test site
// environment.
// @see \Drupal\Core\Extension\ExtensionDiscovery::scan()
$settings['settings']['test_parent_site'] = (object) array('value' => $this->originalSite, 'required' => TRUE);
// Add the parent profile's search path to the child site's search paths.
// @see \Drupal\Core\Extension\ExtensionDiscovery::getProfileDirectories()
$settings['conf']['simpletest.settings']['parent_profile'] = (object) array('value' => $this->originalProfile, 'required' => TRUE);
$settings['settings']['apcu_ensure_unique_prefix'] = (object) array('value' => FALSE, 'required' => TRUE);
$this->writeSettings($settings);
// Allow for test-specific overrides.
$settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php';
if (file_exists($settings_testing_file)) {
// Copy the testing-specific settings.php overrides in place.
copy($settings_testing_file, $directory . '/settings.testing.php');
// Add the name of the testing class to settings.php and include the
// testing specific overrides
file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) . "';\n" . 'include DRUPAL_ROOT . \'/\' . $site_path . \'/settings.testing.php\';' . "\n", FILE_APPEND);
}
$settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml';
if (file_exists($settings_services_file)) {
// Copy the testing-specific service overrides in place.
copy($settings_services_file, $directory . '/services.yml');
}
if ($this->strictConfigSchema) {
// Add a listener to validate configuration schema on save.
$yaml = new \Symfony\Component\Yaml\Yaml();
$services = $yaml->parse($directory . '/services.yml');
$services['services']['simpletest.config_schema_checker'] = ['class' => 'Drupal\\Core\\Config\\Testing\\ConfigSchemaChecker', 'arguments' => ['@config.typed'], 'tags' => [['name' => 'event_subscriber']]];
file_put_contents($directory . '/services.yml', $yaml->dump($services));
}
// Since Drupal is bootstrapped already, install_begin_request() will not
// bootstrap again. Hence, we have to reload the newly written custom
// settings.php manually.
$class_loader = (require DRUPAL_ROOT . '/autoload.php');
Settings::initialize(DRUPAL_ROOT, $this->siteDirectory, $class_loader);
// Execute the non-interactive installer.
require_once DRUPAL_ROOT . '/core/includes/install.core.inc';
install_drupal($class_loader, $parameters);
// Import new settings.php written by the installer.
Settings::initialize(DRUPAL_ROOT, $this->siteDirectory, $class_loader);
foreach ($GLOBALS['config_directories'] as $type => $path) {
$this->configDirectories[$type] = $path;
}
// After writing settings.php, the installer removes write permissions
// from the site directory. To allow drupal_generate_test_ua() to write
// a file containing the private key for drupal_valid_test_ua(), the site
// directory has to be writable.
// TestBase::restoreEnvironment() will delete the entire site directory.
// Not using File API; a potential error must trigger a PHP warning.
chmod($directory, 0777);
$request = \Drupal::request();
$this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', TRUE);
$this->kernel->prepareLegacyRequest($request);
// Force the container to be built from scratch instead of loaded from the
//.........这里部分代码省略.........
示例10: 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), $autoloader);
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);
示例11: setUp
/**
* Overrides WebTestBase::setUp().
*/
protected function setUp()
{
$this->isInstalled = FALSE;
// Define information about the user 1 account.
$this->root_user = new UserSession(array('uid' => 1, 'name' => 'admin', 'mail' => 'admin@example.com', 'pass_raw' => $this->randomMachineName()));
// If any $settings are defined for this test, copy and prepare an actual
// settings.php, so as to resemble a regular installation.
if (!empty($this->settings)) {
// Not using File API; a potential error must trigger a PHP warning.
copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php');
$this->writeSettings($this->settings);
}
// Note that WebTestBase::installParameters() returns form input values
// suitable for a programmed drupal_form_submit().
// @see WebTestBase::translatePostValues()
$this->parameters = $this->installParameters();
// Set up a minimal container (required by WebTestBase).
// @see install_begin_request()
$request = Request::create($GLOBALS['base_url'] . '/core/install.php');
$this->container = new ContainerBuilder();
$request_stack = new RequestStack();
$request_stack->push($request);
$this->container->set('request_stack', $request_stack);
$this->container->setParameter('language.default_values', Language::$defaultValues);
$this->container->register('language.default', 'Drupal\\Core\\Language\\LanguageDefault')->addArgument('%language.default_values%');
$this->container->register('language_manager', 'Drupal\\Core\\Language\\LanguageManager')->addArgument(new Reference('language.default'));
$this->container->register('string_translation', 'Drupal\\Core\\StringTranslation\\TranslationManager')->addArgument(new Reference('language_manager'));
\Drupal::setContainer($this->container);
$this->drupalGet($GLOBALS['base_url'] . '/core/install.php');
// Select language.
$this->setUpLanguage();
// Select profile.
$this->setUpProfile();
// Configure settings.
$this->setUpSettings();
// @todo Allow test classes based on this class to act on further installer
// screens.
// Configure site.
$this->setUpSite();
// Import new settings.php written by the installer.
$request = Request::createFromGlobals();
$class_loader = (require DRUPAL_ROOT . '/core/vendor/autoload.php');
Settings::initialize(DrupalKernel::findSitePath($request), $class_loader);
foreach ($GLOBALS['config_directories'] as $type => $path) {
$this->configDirectories[$type] = $path;
}
// After writing settings.php, the installer removes write permissions
// from the site directory. To allow drupal_generate_test_ua() to write
// a file containing the private key for drupal_valid_test_ua(), the site
// directory has to be writable.
// WebTestBase::tearDown() will delete the entire test site directory.
// Not using File API; a potential error must trigger a PHP warning.
chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777);
$this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE);
$this->kernel->prepareLegacyRequest($request);
$this->container = $this->kernel->getContainer();
$config = $this->container->get('config.factory');
// Manually configure the test mail collector implementation to prevent
// tests from sending out e-mails and collect them in state instead.
$config->get('system.mail')->set('interface.default', 'test_mail_collector')->save();
// When running from run-tests.sh we don't get an empty current path which
// would indicate we're on the home page.
$path = current_path();
if (empty($path)) {
_current_path('run-tests');
}
$this->isInstalled = TRUE;
}
示例12: initSettings
/**
* Initialize settings created during install.
*/
protected function initSettings()
{
Settings::initialize(DRUPAL_ROOT, $this->siteDirectory, $this->classLoader);
foreach ($GLOBALS['config_directories'] as $type => $path) {
$this->configDirectories[$type] = $path;
}
// After writing settings.php, the installer removes write permissions
// from the site directory. To allow drupal_generate_test_ua() to write
// a file containing the private key for drupal_valid_test_ua(), the site
// directory has to be writable.
// TestBase::restoreEnvironment() will delete the entire site directory.
// Not using File API; a potential error must trigger a PHP warning.
chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777);
}
示例13: 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);
示例14: DbDumpApplication
#!/usr/bin/env php
<?php
use Drupal\Core\Command\DbDumpApplication;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
if (PHP_SAPI !== 'cli') {
return;
}
// Bootstrap.
$autoloader = (require __DIR__ . '/../../autoload.php');
require_once __DIR__ . '/../includes/bootstrap.inc';
$request = Request::createFromGlobals();
Settings::initialize(dirname(dirname(__DIR__)), DrupalKernel::findSitePath($request), $autoloader);
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
// Run the database dump command.
$application = new DbDumpApplication(Database::getConnection(), \Drupal::moduleHandler());
$application->run();
示例15: initializeSettings
/**
* Initializes the kernel's site path and the Settings singleton.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request that will be used to determine the site path.
*/
protected function initializeSettings(Request $request)
{
$site_path = static::findSitePath($request);
$this->setSitePath($site_path);
Settings::initialize($site_path, $this->classLoader);
}