You are here

public static function Redirect::generateHash in Redirect 8

Generates a unique hash for identification purposes.

Parameters

string $source_path: Source path of the redirect.

array $source_query: Source query as an array.

string $language: Redirect language.

Return value

string Base 64 hash.

5 calls to Redirect::generateHash()
Redirect::preSave in src/Entity/Redirect.php
Acts on an entity before the presave hook is invoked.
RedirectAPITest::testRedirectEntity in tests/src/Kernel/RedirectAPITest.php
Test redirect entity logic.
RedirectForm::validateForm in src/Form/RedirectForm.php
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level…
RedirectRepository::findMatchingRedirect in src/RedirectRepository.php
Gets a redirect for given path, query and language.
redirect_update_8100 in ./redirect.install
Rehash redirects to account for case insensitivity.

File

src/Entity/Redirect.php, line 62

Class

Redirect
The redirect entity class.

Namespace

Drupal\redirect\Entity

Code

public static function generateHash($source_path, array $source_query, $language) {
  $hash = [
    'source' => mb_strtolower($source_path),
    'language' => $language,
  ];
  if (!empty($source_query)) {
    $hash['source_query'] = $source_query;
  }
  redirect_sort_recursive($hash, 'ksort');
  return Crypt::hashBase64(serialize($hash));
}