function LockFileValidator::storeHash
Stores the XXH64 hash of the active lock file.
We store the hash of the lock file itself, rather than its content-hash value, which is actually a hash of certain parts of composer.json. Our aim is to verify that the actual installed packages have not changed unexpectedly; we don't care about the contents of composer.json.
Parameters
\Drupal\package_manager\Event\PreCreateEvent $event: The event being handled.
File
-
core/
modules/ package_manager/ src/ Validator/ LockFileValidator.php, line 90
Class
- LockFileValidator
- Checks that the active lock file is unchanged during stage operations.
Namespace
Drupal\package_manager\ValidatorCode
public function storeHash(PreCreateEvent $event) : void {
$active_lock_file_path = $this->pathLocator
->getProjectRoot() . DIRECTORY_SEPARATOR . 'composer.lock';
$hash = $this->getHash($active_lock_file_path);
if ($hash) {
$this->keyValue
->set(static::KEY, $hash);
}
else {
$event->addError([
$this->t('The active lock file (@file) does not exist.', [
'@file' => $active_lock_file_path,
]),
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.