diff --git a/core/includes/common.inc b/core/includes/common.inc index ea06248..9674314 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -505,10 +505,12 @@ function drupal_get_query_array($query) { * * @see \Drupal\Core\Routing\PathBasedGeneratorInterface::httpBuildQuery() * @see drupal_get_query_parameters() + * @deprecated as of Drupal 8.0. Use + * Drupal::service('router.generator')->httpBuildQuery() instead. * @ingroup php_wrappers */ function drupal_http_build_query(array $query, $parent = '') { - return Drupal::Service('router.generator')->httpBuildQuery($query, $parent); + return Drupal::service('router.generator')->httpBuildQuery($query, $parent); } /** @@ -539,7 +541,7 @@ function drupal_get_destination() { } else { $path = current_path(); - $query = Drupal::Service('router.generator')->httpBuildQuery(drupal_get_query_parameters()); + $query = Drupal::service('router.generator')->httpBuildQuery(drupal_get_query_parameters()); if ($query != '') { $path .= '?' . $query; } @@ -1213,7 +1215,7 @@ function valid_number_step($value, $step, $offset = 0.0) { */ function drupal_strip_dangerous_protocols($uri) { $allowed_protocols = array_flip(config('system.filter')->get('protocols') ?: array('http', 'https')); - return Drupal::Service('router.generator')->stripDisallowedProtocols($uri, $allowed_protocols); + return Drupal::service('router.generator')->stripDisallowedProtocols($uri, $allowed_protocols); } /** diff --git a/core/lib/Drupal/Core/Routing/PathBasedGeneratorInterface.php b/core/lib/Drupal/Core/Routing/PathBasedGeneratorInterface.php index 53b7d63..7a0d7e5 100644 --- a/core/lib/Drupal/Core/Routing/PathBasedGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/PathBasedGeneratorInterface.php @@ -33,7 +33,7 @@ * - The special string '' generates a link to the site's base URL. * - If your external URL contains a query (e.g. http://example.com/foo?a=b), * then you can either URL encode the query keys and values yourself and - * include them in $path, or use $options['query'] to let this function + * include them in $path, or use $options['query'] to let this method * URL encode them. * @param $options * (optional) An associative array of additional options, with the following @@ -84,6 +84,16 @@ public function setRequest(Request $request); /** * Sets the baseUrl property. * + * This property is made up of scheme, host and base_path, e.g. + * 'http://www.example.com/mydrupalinstall/' + * + * The base url is usually set by the request but we allow it to be set + * independent of the request so that code that calls url() outside the context + * of a request can use the global $base_url variable to set this value. + * + * @todo Remove this once the url() function no longer supports being called + * when there is no request. + * * @var string $url * The base url to use for url generation. */ @@ -92,6 +102,16 @@ public function setBaseUrl($url); /** * Sets the basePath property. * + * This will be either '/' or '[subdir]/', where [subdir] is the name of the + * subdirectory that Drupal is running in. + * + * The base path is usually set by the request but we allow it to be set + * independent of the request so that code that calls url() outside the context + * of a request can use the global $base_url variable to set this value. + * + * @todo Remove this once the url() function no longer supports being called + * when there is no request. + * * @var string $path * The base path to use for url generation. */ @@ -100,6 +120,15 @@ public function setBasePath($path); /** * Sets the scriptPath property. * + * The script path is usually set by the request and is either 'index.php' or + * the empty string, depending on whether the request path actually contains + * the script path or not. We allow it to be set independent of the request so + * that code that calls url() outside the context of a request can use the global + * $script_path variable to set this value. + * + * @todo Remove this once the url() function no longer supports being called + * when there is no request. + * * @var string $path * The script path to use for url generation. */ diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index 956d4ca..efd3120 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -332,7 +332,8 @@ protected function processPath($path, &$options = array()) { * Returns whether or not the url generator has been initialized. * * @return bool - * Returns TRUE if the server variables have been set, FALSE otherwise. + * Returns TRUE if the basePath, baseUrl and scriptPath properties have been + * set, FALSE otherwise. */ protected function initialized() { return isset($this->basePath) && isset($this->baseUrl) && isset($this->scriptPath); diff --git a/core/modules/image/image.module b/core/modules/image/image.module index d112239..3933d28 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -743,7 +743,7 @@ function image_style_url($style_name, $path, $clean_urls = NULL) { // Assume clean URLs unless the request tells us otherwise. $clean_urls = TRUE; try { - $request = Drupal::service('request'); + $request = Drupal::request(); $clean_urls = $request->attributes->get('clean_urls'); } catch (ServiceNotFoundException $e) { diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php index d9f703b..89a1bd6 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php @@ -40,18 +40,15 @@ function setUp() { $edit = array(); $edit['predefined_langcode'] = 'fr'; $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->rebuildContainer(); // Make French the default language. $edit = array( 'site_default_language' => 'fr', ); $this->drupalpost('admin/config/regional/settings', $edit, t('Save configuration')); - $this->rebuildContainer(); // Delete English. $this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete')); - $this->rebuildContainer(); // Verify that French is the only language. $this->assertFalse(language_multilingual(), 'Site is mono-lingual'); @@ -60,7 +57,7 @@ function setUp() { // Set language detection to URL. $edit = array('language_interface[enabled][language-url]' => TRUE); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); - $this->rebuildContainer(); + // Force languages to be initialized. drupal_language_initialize(); }