Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
WIP on #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed Jul 20, 2020
1 parent 7a16bde commit 95da63d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/doi_datacite/src/Minter/Dois.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public function mint($entity, $extra = NULL) {
// We only want to execute mint() once per node (e.g., if there's
// a Context Reaction in addtion to the user doing it via the
// node form).
static $node_seen = FALSE;
if ($node_seen) {
static $seen_nodes = [];
if (in_array($entity->uuid(), $seen_nodes)) {
return FALSE;
}
$node_seen = TRUE;
$seen_nodes[] = $entity->uuid();

global $base_url;
// This minter needs $extra.
if (is_null($extra)) {
\Drupal::logger('doi_datacite')->info(t("'Extra' information is required to mint a DOI for node \"@title\" (UUID @uuid).", ['@title' => $entity->get('title')->value, '@uuid' => $entity->uuid()]));
return NULL;
}

Expand All @@ -104,8 +104,8 @@ public function mint($entity, $extra = NULL) {
$doi_field_values = $entity->get($doi_field_name)->getValue();
if (array_key_exists('value', $doi_field_values[0])) {
if (preg_match('/' . $doi_prefix . '\//', $doi_field_values[0]['value'])) {
// \Drupal::logger('doi_datacite')->info(t("Node \"@title\" (UUID @uuid) already has a DOI (@doi), Context Reaction not adding one.", ['@title' => $entity->get('title')->value, '@uuid' => $entity->uuid(), '@doi' => $doi_field_values[0]['value']]));
return NULL;
\Drupal::logger('doi_datacite')->info(t("Node \"@title\" (UUID @uuid) already has a DOI (@doi), Minter is not adding another one.", ['@title' => $entity->get('title')->value, '@uuid' => $entity->uuid(), '@doi' => $doi_field_values[0]['value']]));
return FALSE;
}
}
}
Expand All @@ -119,6 +119,7 @@ public function mint($entity, $extra = NULL) {
$doi = $this->doi_prefix . '/' . $suffix;
}

global $base_url;
// If $extra is from the Views Bulk Operations Action
// or a Context Reaction (i.e., it's an array).
if (is_array($extra)) {
Expand Down

0 comments on commit 95da63d

Please sign in to comment.