Skip to content
Merged
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
14 changes: 14 additions & 0 deletions src/Plugin/OaiMetadataMap/DgiStandard.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ protected function addFields(ContentEntityInterface $entity): void {
if (static::THUMBNAIL_ELEMENT) {
$this->addThumbnail($entity, static::THUMBNAIL_ELEMENT);
}
// Fallback to the label if no title.
$this->addFallbackTitle($entity);
}

/**
Expand Down Expand Up @@ -651,4 +653,16 @@ protected function isParagraphField($paragraph_name) {
return isset($this->paragraphMapping[$paragraph_name]);
}

/**
* Ensures a title is set if one hasn't been added.
*
* * @param \Drupal\Core\Entity\ContentEntityInterface $entity
* * The entity being rendered.
*/
protected function addFallbackTitle(ContentEntityInterface $entity): void {
if (!isset($this->elements[static::TITLE_ELEMENT_MAIN])) {
$this->elements[static::TITLE_ELEMENT_MAIN] = (string) $entity->label();
}
}

Comment thread
jordandukart marked this conversation as resolved.
}