function MediaLibraryState::getHash
Same name in other branches
- 9 core/modules/media_library/src/MediaLibraryState.php \Drupal\media_library\MediaLibraryState::getHash()
- 8.9.x core/modules/media_library/src/MediaLibraryState.php \Drupal\media_library\MediaLibraryState::getHash()
- 11.x 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.
2 calls to MediaLibraryState::getHash()
- MediaLibraryState::isValidHash in core/
modules/ media_library/ src/ MediaLibraryState.php - Validate a hash for the state object.
- MediaLibraryState::__construct in core/
modules/ media_library/ src/ MediaLibraryState.php
File
-
core/
modules/ media_library/ src/ MediaLibraryState.php, line 180
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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.