public static function BiblioContributorUtility::generateBiblioContributorMd5 in Bibliography Module 7.3
Generates an md5 string based on a biblio contributor object. The md5 is later used to determine whether or not two Biblio Contributor objects are the same and prevent duplications.
Parameters
$biblio_contributor: Biblio Contributor object.
Return value
MD5 string that represents the given biblio contributor.
2 calls to BiblioContributorUtility::generateBiblioContributorMd5()
- BiblioContributor::save in includes/
biblio.contributor.controller.inc - Overrides Entity::save().
- BiblioContributorUtility::getBiblioContributor in includes/
BiblioContributorUtility.inc - Returns saved biblio contributor object; Returns an existing contributor if the given contributor was found, otherwise creates it first.
File
- includes/
BiblioContributorUtility.inc, line 222 - Helper class for handling Biblio Contributors.
Class
- BiblioContributorUtility
- @file Helper class for handling Biblio Contributors.
Code
public static function generateBiblioContributorMd5(BiblioContributor $biblio_contributor) {
// The property 'name' must be set in every contributor, since it is used as
// the title of the entity. We set it now, right before generating the MD5,
// so it will be included in the MD5 calculation.
$biblio_contributor->name = $biblio_contributor->lastname ? $biblio_contributor->firstname . ' ' . $biblio_contributor->lastname : $biblio_contributor->firstname;
$clone = clone $biblio_contributor;
unset($clone->cid);
unset($clone->revision_id);
unset($clone->changed);
unset($clone->created);
unset($clone->is_new);
unset($clone->md5);
return md5(serialize($clone));
}