protected function LinkCollectionNormalizer::hashByHref in JSON:API 8.2
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 src/
Normalizer/ LinkCollectionNormalizer.php - Normalizes an object into a set of arrays/scalars.
File
- 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);
}