function UrlHelper::encodePath

Same name in other branches
  1. 9 core/lib/Drupal/Component/Utility/UrlHelper.php \Drupal\Component\Utility\UrlHelper::encodePath()
  2. 10 core/lib/Drupal/Component/Utility/UrlHelper.php \Drupal\Component\Utility\UrlHelper::encodePath()
  3. 11.x core/lib/Drupal/Component/Utility/UrlHelper.php \Drupal\Component\Utility\UrlHelper::encodePath()

Encodes a Drupal path for use in a URL.

For aesthetic reasons slashes are not escaped.

Parameters

string $path: The Drupal path to encode.

Return value

string The encoded path.

5 calls to UrlHelper::encodePath()
ContextualLinks::render in core/modules/contextual/src/Plugin/views/field/ContextualLinks.php
Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
FieldWebTest::testAlterUrl in core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
Tests rewriting the output to a link.
file_create_url in core/includes/file.inc
Creates a web-accessible URL for a stream to an external or local file.
PublicStream::getExternalUrl in core/lib/Drupal/Core/StreamWrapper/PublicStream.php
Returns a web accessible URL for the resource.
UrlHelperTest::testEncodePath in core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
Tests path encoding.

File

core/lib/Drupal/Component/Utility/UrlHelper.php, line 195

Class

UrlHelper
Helper class URL based methods.

Namespace

Drupal\Component\Utility

Code

public static function encodePath($path) {
    return str_replace('%2F', '/', rawurlencode($path));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.