You are here

public static function UrlData::encode in Commerce Core 8.2

Encodes the given data.

Parameters

array $data: The data.

Return value

string The encoded data.

3 calls to UrlData::encode()
TaxNumberDefaultFormatter::viewElements in modules/tax/src/Plugin/Field/FieldFormatter/TaxNumberDefaultFormatter.php
Builds a renderable array for a field value.
TaxNumberTest::testVerificationEndpointAccess in modules/tax/tests/src/FunctionalJavascript/TaxNumberTest.php
Tests access control for the verification endpoints.
UrlDataTest::testEncodeDecode in tests/src/Unit/UrlDataTest.php
::covers encode ::covers decode.

File

src/UrlData.php, line 19

Class

UrlData
Encodes and decodes array data in a URL-safe way.

Namespace

Drupal\commerce

Code

public static function encode(array $data) {
  $data = json_encode($data);

  // URL-safe Base64 encoding (base64url).
  $data = str_replace([
    '+',
    '/',
    '=',
  ], [
    '-',
    '_',
    '',
  ], base64_encode($data));
  return $data;
}