public function MediaLibraryState::getHash in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media_library/src/MediaLibraryState.php \Drupal\media_library\MediaLibraryState::getHash()
- 9 core/modules/media_library/src/MediaLibraryState.php \Drupal\media_library\MediaLibraryState::getHash()
Get the hash for the state object.
Return value
string The hashed parameters.
File
- core/
modules/ media_library/ src/ MediaLibraryState.php, line 177
Class
- MediaLibraryState
- A value object for the media library state.
Namespace
Drupal\media_libraryCode
public function getHash() {
// Create a hash from the required state parameters and the serialized
// optional opener-specific parameters. Sort the allowed types and
// opener parameters so that differences in order do not result in
// different hashes.
$allowed_media_type_ids = array_values($this
->getAllowedTypeIds());
sort($allowed_media_type_ids);
$opener_parameters = $this
->getOpenerParameters();
ksort($opener_parameters);
$hash = implode(':', [
$this
->getOpenerId(),
implode(':', $allowed_media_type_ids),
$this
->getSelectedTypeId(),
$this
->getAvailableSlots(),
serialize($opener_parameters),
]);
return Crypt::hmacBase64($hash, \Drupal::service('private_key')
->get() . Settings::getHashSalt());
}