You are here

protected function JsonapiHypermediaLinkCollectionNormalizer::hashLinkNormalization in JSON:API Hypermedia 8

Hashes a link normalization.

Parameters

array $link: A link to be hashed.

Return value

string A 7 character alphanumeric hash.

1 call to JsonapiHypermediaLinkCollectionNormalizer::hashLinkNormalization()
JsonapiHypermediaLinkCollectionNormalizer::normalize in src/Normalizer/JsonapiHypermediaImpostor/JsonapiHypermediaLinkCollectionNormalizer.php
Normalizes an object into a set of arrays/scalars.

File

src/Normalizer/JsonapiHypermediaImpostor/JsonapiHypermediaLinkCollectionNormalizer.php, line 151

Class

JsonapiHypermediaLinkCollectionNormalizer
Class JsonApiHypermediaLinkCollectionNormalizer.

Namespace

Drupal\jsonapi\Normalizer\JsonapiHypermediaImpostor

Code

protected function hashLinkNormalization(array $link) {
  if (!$this->hashSalt) {
    $this->hashSalt = Crypt::randomBytesBase64();
  }
  return substr(str_replace([
    '-',
    '_',
  ], '', Crypt::hashBase64($this->hashSalt . Json::encode($link))), 0, 7);
}