protected function LinkCollectionNormalizer::hashByHref in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/src/Normalizer/LinkCollectionNormalizer.php \Drupal\jsonapi\Normalizer\LinkCollectionNormalizer::hashByHref()
Hashes a link by its href.
Parameters
\Drupal\jsonapi\JsonApiResource\Link $link: A link to be hashed.
Return value
string A 7 character alphanumeric hash.
1 call to LinkCollectionNormalizer::hashByHref()
- LinkCollectionNormalizer::normalize in core/
modules/ jsonapi/ src/ Normalizer/ LinkCollectionNormalizer.php - Normalizes an object into a set of arrays/scalars.
File
- core/
modules/ jsonapi/ src/ Normalizer/ LinkCollectionNormalizer.php, line 93
Class
- LinkCollectionNormalizer
- Normalizes a LinkCollection object.
Namespace
Drupal\jsonapi\NormalizerCode
protected function hashByHref(Link $link) {
if (!$this->hashSalt) {
$this->hashSalt = Crypt::randomBytesBase64();
}
return substr(str_replace([
'-',
'_',
], '', Crypt::hashBase64($this->hashSalt . $link
->getHref())), 0, 7);
}