Issue #2342925 by tim.plunkett: Simplify url() in order for the installer to function without it.

8.0.x
webchick 2014-09-22 20:55:51 -07:00
parent 9b16aeb57b
commit 5baf8db0d3
3 changed files with 14 additions and 15 deletions

View File

@ -642,21 +642,7 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromPath().
*/
function url($path = NULL, array $options = array()) {
$generator = \Drupal::urlGenerator();
try {
$url = $generator->generateFromPath($path, $options);
}
catch (GeneratorNotInitializedException $e) {
// Fallback to using globals.
// @todo Remove this once there is no code that calls url() when there is
// no request.
global $base_url, $base_path, $script_path;
$generator->setBasePath($base_path);
$generator->setBaseUrl($base_url . '/');
$generator->setScriptPath($script_path);
$url = $generator->generateFromPath($path, $options);
}
return $url;
return \Drupal::urlGenerator()->generateFromPath($path, $options);
}
/**

View File

@ -886,6 +886,9 @@ function install_display_output($output, $install_state) {
// reached in case of an early installer error.
drupal_maintenance_theme();
// Ensure the URL generator is initialized.
\Drupal::urlGenerator()->updateFromRequest();
drupal_page_header();
// Prevent install.php from being indexed when installed in a sub folder.

View File

@ -22,6 +22,16 @@ class NullGenerator extends UrlGenerator {
public function __construct() {
}
/**
* {@inheritdoc}
*/
public function updateFromRequest() {
global $base_url, $base_path, $script_path;
$this->basePath = $base_path;
$this->baseUrl = $base_url . '/';
$this->scriptPath = $script_path;
}
/**
* {@inheritdoc}
*