function UrlHelper::encodePath

Same name in other branches
  1. 9 core/lib/Drupal/Component/Utility/UrlHelper.php \Drupal\Component\Utility\UrlHelper::encodePath()
  2. 8.9.x core/lib/Drupal/Component/Utility/UrlHelper.php \Drupal\Component\Utility\UrlHelper::encodePath()
  3. 10 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.

7 calls to UrlHelper::encodePath()
BigPipeTest::testNoJsDetection in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe's no-JS detection.
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.
FileUrlGenerator::generate in core/lib/Drupal/Core/File/FileUrlGenerator.php
Creates a root-relative web-accessible URL object.
FileUrlGenerator::generatePath in core/lib/Drupal/Core/File/FileUrlGenerator.php
Generate a URL path.

... See full list

File

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

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.