MDL-64777 analytics: Add method for identifying a model declaration

This is intended to be used to as a declaration identifier in HTML or as
a HTTP parameter value.
This commit is contained in:
David Mudrák
2019-04-15 08:16:58 +02:00
parent bef0fe2000
commit 01d620ee67
2 changed files with 53 additions and 0 deletions
+10
View File
@@ -770,4 +770,14 @@ class manager {
return $created;
}
/**
* Returns a string uniquely representing the given model declaration.
*
* @param array $model Model declaration
* @return string complying with PARAM_ALPHANUM rules and starting with an 'id' prefix
*/
public static function model_declaration_identifier(array $model) : string {
return 'id'.sha1(serialize($model));
}
}