Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2550 Add support for future dates by setting publication status to "forthcoming" #2594

Merged
merged 17 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/custom/az_publication/az_publication.module
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ function az_publication_node_view(array &$build, EntityInterface $entity, Entity
// Handle publication date if available.
if (!empty($entity->field_az_publication_date->value)) {
$blob->issued = _az_publication_publication_date_object($entity);
if (isset($blob->issued->{'status'}) && $blob->issued->{'status'} === 'forthcoming') {
$blob->status = t('forthcoming');
}
}
// Handle accessed date if available.
if (!empty($entity->field_az_accessed_date->value)) {
Expand Down Expand Up @@ -465,6 +468,14 @@ function _az_publication_publication_date_object(EntityInterface $entity) {
if (!empty($entity->field_az_publication_approximate->value)) {
$date->{'circa'} = 1;
}
// Handle forthcoming/future dates.
if (!empty($entity->field_az_publication_date->value)) {
$issue_date = strtotime($entity->field_az_publication_date->value);
$now = \Drupal::time()->getCurrentTime();
if ($issue_date > $now) {
$date->{'status'} = 'forthcoming';
}
}
return $date;
}

Expand Down
Loading