Skip to content

Commit

Permalink
Add title lookuup for issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobSanford committed Aug 13, 2024
1 parent b1b1189 commit 7387929
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ digital_serial_issue.title_search:
_title: 'Issue Search Results'
requirements:
_permission: 'view published serial issue entities'

digital_serial_issue.issue_title_search:
path: '/serials-issue-title-search/{issue_id}'
defaults:
_controller: '\Drupal\digital_serial_issue\Controller\DigitalSerialIssueSearchController::getIssueTitleId'
_title: 'Title Search Results'
requirements:
_permission: 'view published serial issue entities'
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getYearIssues($title_id, $issue_year) {
}

/**
* Gets an entity's issues from a matching year.
* Gets an entity's issues from a title.
*/
public function getTitleIssues($title_id) {
$query = \Drupal::entityQuery('digital_serial_issue')
Expand All @@ -77,6 +77,24 @@ public function getTitleIssues($title_id) {
);
}

/**
* Gets an issue's parent title.
*/
public function getIssueTitleId($issue_id) {
$issue = \Drupal::entityTypeManager()
->getStorage('digital_serial_issue')
->load($issue_id);
$title_id = $issue->parent_title->target_id;

return new JsonResponse(
[
'data' => $title_id,
'method' => 'GET',
'status' => 200,
]
);
}

/**
* Remove the null string placeholder from a string and replace it with NULL.
*
Expand Down

0 comments on commit 7387929

Please sign in to comment.