');
$variables['language'] = $language_interface;
$variables['logo'] = theme_get_setting('logo.url');
diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php
index 7621a48..f8e0e0b 100644
--- a/core/lib/Drupal.php
+++ b/core/lib/Drupal.php
@@ -687,4 +687,14 @@ public static function destination() {
return static::getContainer()->get('redirect.destination');
}
+ /**
+ * Returns the application helper.
+ *
+ * @return \Drupal\Core\App
+ * The application helper.
+ */
+ public static function app() {
+ return static::getContainer()->get('app');
+ }
+
}
diff --git a/core/lib/Drupal/Core/App.php b/core/lib/Drupal/Core/App.php
index 82997d9..68ee1fc 100644
--- a/core/lib/Drupal/Core/App.php
+++ b/core/lib/Drupal/Core/App.php
@@ -49,7 +49,7 @@ class App {
* The absolute path to the Drupal root directory.
*/
public function __construct($root) {
- $this->root = $root;
+ $this->root = realpath($root);
}
/**
@@ -115,7 +115,7 @@ protected function prepareBasePath() {
$this->basePath = $this->request->getBasePath();
if ($this->basePath) {
- $script_path = $this->request->server->get('SCRIPT_FILENAME');
+ $script_path = realpath($this->request->server->get('SCRIPT_FILENAME'));
// Remove trailing filename from path to front controller.
$script_base = substr($script_path, 0, -strlen(basename($script_path)) - 1);
// Remove leading document root from path to front controller.
diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
index ffa1e0c..117a81d 100644
--- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
+++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
@@ -29,8 +29,8 @@ public function __construct(TranslationInterface $string_translation) {
To upgrade an existing installation, proceed to the update script.
View your existing site.
', array(
- '!base-url' => \Drupal::service('app')->getBaseUrl(),
- '!update-url' => \Drupal::service('app')->getBasePath() . '/update.php',
+ '!base-url' => \Drupal::app()->getBaseUrl(),
+ '!update-url' => \Drupal::app()->getBasePath() . '/update.php',
));
parent::__construct($message, $title);
}
diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
index 75183a7..b9134f0 100644
--- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php
+++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
@@ -342,12 +342,12 @@ protected static function htmlToMailUrls($match = NULL, $reset = FALSE) {
}
else {
if (empty(static::$regexp)) {
- static::$regexp = '@^' . preg_quote(\Drupal::service('app')->getBasePath() . '/', '@') . '@';
+ static::$regexp = '@^' . preg_quote(\Drupal::app()->getBasePath() . '/', '@') . '@';
}
if ($match) {
list(, , $url, $label) = $match;
// Ensure all URLs are absolute.
- static::$urls[] = strpos($url, '://') ? $url : preg_replace(static::$regexp, \Drupal::service('app')->getBaseUrl() . '/', $url);
+ static::$urls[] = strpos($url, '://') ? $url : preg_replace(static::$regexp, \Drupal::app()->getBaseUrl() . '/', $url);
return $label . ' [' . count(static::$urls) . ']';
}
}
diff --git a/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php b/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php
index 0be5fb7..1aca77e 100644
--- a/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php
+++ b/core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php
@@ -35,7 +35,7 @@ protected function isLocal($url) {
*/
protected function getBaseUrl() {
if (!isset($this->baseUrl)) {
- $this->baseUrl = \Drupal::service('app')->getBaseUrl();
+ $this->baseUrl = \Drupal::app()->getBaseUrl();
}
return $this->baseUrl;
}
diff --git a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php
index 4951373..f00881e 100644
--- a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php
+++ b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php
@@ -53,7 +53,7 @@ public function getDirectoryPath() {
*/
public function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
- return \Drupal::service('app')->getBaseUrl() . '/' . self::getDirectoryPath() . '/' . UrlHelper::encodePath($path);
+ return \Drupal::app()->getBaseUrl() . '/' . self::getDirectoryPath() . '/' . UrlHelper::encodePath($path);
}
/**
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index 660181f..3aa3373 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -464,7 +464,7 @@ function template_preprocess_book_export_html(&$variables) {
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
$variables['title'] = SafeMarkup::checkPlain($variables['title']);
- $variables['base_url'] = \Drupal::service('app')->getBaseUrl();
+ $variables['base_url'] = \Drupal::app()->getBaseUrl();
$variables['language'] = $language_interface;
$variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL);
$variables['head'] = drupal_get_html_head();
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index ad9488b..346ea98 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -471,7 +471,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
// Return the path to where this CSS file originated from, stripping
// off the name of the file at the end of the path.
- $css_optimizer->rewriteFileURIBasePath = \Drupal::service('app')->getBasePath() . '/' . dirname($paths['source'] . $file) . '/';
+ $css_optimizer->rewriteFileURIBasePath = \Drupal::app()->getBasePath() . '/' . dirname($paths['source'] . $file) . '/';
// Prefix all paths within this CSS file, ignoring absolute paths.
$style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style);
@@ -556,7 +556,7 @@ function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style) {
// Replace paths to images.
foreach ($paths['map'] as $before => $after) {
- $before = \Drupal::service('app')->getBasePath() . '/' . $paths['source'] . $before;
+ $before = \Drupal::app()->getBasePath() . '/' . $paths['source'] . $before;
$before = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $before);
$output = str_replace($before, $after, $output);
}
diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php
index 7568187..f46d87a 100644
--- a/core/modules/comment/src/Plugin/views/row/Rss.php
+++ b/core/modules/comment/src/Plugin/views/row/Rss.php
@@ -97,7 +97,7 @@ public function render($row) {
),
array(
'key' => 'guid',
- 'value' => 'comment ' . $comment->id() . ' at ' . \Drupal::service('app')->getBaseUrl(),
+ 'value' => 'comment ' . $comment->id() . ' at ' . \Drupal::app()->getBaseUrl(),
'attributes' => array('isPermaLink' => 'false'),
),
);
diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module
index 039c7fb..402e1a6 100644
--- a/core/modules/file/tests/file_test/file_test.module
+++ b/core/modules/file/tests/file_test/file_test.module
@@ -260,7 +260,7 @@ function file_test_file_url_alter(&$uri) {
$path = str_replace('\\', '/', $path);
// Generate a root-relative URL.
- $uri = \Drupal::service('app')->getBasePath() . '/' . $path;
+ $uri = \Drupal::app()->getBasePath() . '/' . $path;
}
}
// Test alteration of file URLs to use protocol-relative URLs.
@@ -283,7 +283,7 @@ function file_test_file_url_alter(&$uri) {
$path = str_replace('\\', '/', $path);
// Generate a protocol-relative URL.
- $uri = '/' . \Drupal::service('app')->getBasePath() . '/' . $path;
+ $uri = '/' . \Drupal::app()->getBasePath() . '/' . $path;
}
}
}
diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php
index 6b9cce6..ace33da 100644
--- a/core/modules/filter/filter.api.php
+++ b/core/modules/filter/filter.api.php
@@ -35,7 +35,7 @@ function hook_filter_info_alter(&$info) {
*/
function hook_filter_secure_image_alter(&$image) {
// Turn an invalid image into an error indicator.
- $image->setAttribute('src', \Drupal::service('app')->getBasePath() . '/core/misc/icons/ea2800/error.svg');
+ $image->setAttribute('src', \Drupal::app()->getBasePath() . '/core/misc/icons/ea2800/error.svg');
$image->setAttribute('alt', t('Image removed.'));
$image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.'));
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index b1ac5ab..7816f63 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -786,7 +786,7 @@ function _filter_html_escape($text) {
*/
function _filter_html_image_secure_process($text) {
// Find the path (e.g. '/') to Drupal root.
- $base_path = \Drupal::service('app')->getBasePath() . '/';
+ $base_path = \Drupal::app()->getBasePath() . '/';
$base_path_length = Unicode::strlen($base_path);
// Find the directory on the server where index.php resides.
@@ -834,7 +834,7 @@ function _filter_html_image_secure_process($text) {
*/
function filter_filter_secure_image_alter(&$image) {
// Turn an invalid image into an error indicator.
- $image->setAttribute('src', \Drupal::service('app')->getBasePath() . '/core/misc/icons/ea2800/error.svg');
+ $image->setAttribute('src', \Drupal::app()->getBasePath() . '/core/misc/icons/ea2800/error.svg');
$image->setAttribute('alt', t('Image removed.'));
$image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.'));
$image->setAttribute('height', '16');
diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
index 5dbdb2d..3e3e108 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
@@ -100,7 +100,7 @@ public function tips($long = FALSE) {
$output .= '' . $this->t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '
';
$output .= '' . $this->t('For more information see W3C\'s HTML Specifications or use your favorite search engine to find other sites that explain HTML.', array('@html-specifications' => 'http://www.w3.org/TR/html/')) . '
';
$tips = array(
- 'a' => array($this->t('Anchors are used to make links to other pages.'), '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . ''),
+ 'a' => array($this->t('Anchors are used to make links to other pages.'), '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . ''),
'br' => array($this->t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), $this->t('Text with
line break')),
'p' => array($this->t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '' . $this->t('Paragraph one.') . '
' . $this->t('Paragraph two.') . '
'),
'strong' => array($this->t('Strong', array(), array('context' => 'Font weight')), '' . $this->t('Strong', array(), array('context' => 'Font weight')) . ''),
diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php
index 1c42e01..f67946e 100644
--- a/core/modules/node/src/Plugin/views/row/Rss.php
+++ b/core/modules/node/src/Plugin/views/row/Rss.php
@@ -124,7 +124,7 @@ public function render($row) {
),
array(
'key' => 'guid',
- 'value' => $node->id() . ' at ' . \Drupal::service('app')->getBaseUrl(),
+ 'value' => $node->id() . ' at ' . \Drupal::app()->getBaseUrl(),
'attributes' => array('isPermaLink' => 'false'),
),
);
diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
index 496349b..617daa0 100644
--- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -1272,7 +1272,7 @@ public function renderText($alter) {
$more_link_path = strip_tags(Html::decodeEntities($this->viewsTokenReplace($more_link_path, $tokens)));
// Make sure that paths which were run through _url() work as well.
- $base_path = \Drupal::service('app')->getBasePath() . '/';
+ $base_path = \Drupal::app()->getBasePath() . '/';
// Checks whether the path starts with the base_path.
if (strpos($more_link_path, $base_path) === 0) {
$more_link_path = Unicode::substr($more_link_path, Unicode::strlen($base_path));