Skip to content

Commit

Permalink
fix: This is the controller we invoke, so make it return its response…
Browse files Browse the repository at this point in the history
… object.

Even if nothing else happens to it, at least this way we do not trigger a spurious PHP error about needing to return a response. That will *hopefully* sort the last of the on-going GMS errors. Until the site is updated to Drupal 10.

Refs: OPS-9090
  • Loading branch information
cafuego committed Oct 27, 2023
1 parent 83b94fd commit 2052aaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function viewPrint($export_type, $entity_type, $entity_id) {
$response = new RedirectResponse($base_url, 301);
$response->send();
}
return $response;

}

Expand Down Expand Up @@ -208,16 +209,24 @@ public function downloadPdf($entity_type, $entity_id) {
</style>
</head>
<body>' . $content . '</body>
</html>';
echo $html;
die;
</html>';

// This could *possibly* be an HtmlResponse but things seem to work as-is.
$response = new Response();
$response->headers->set('Pragma', 'no-cache');
$response->headers->set('Content-type', 'text/html; charset=utf-8');
$response->headers->set('Cache-control', 'private');
$response->headers->set('Content-length', strlen($html));
$response->setContent($html);
$response->send();
}
else {
global $base_url;
$this->messenger()->addMessage($this->t('Access denied.'), 'error');
$response = new RedirectResponse($base_url, 301);
$response->send();
}
return $response;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public function viewPrint($export_type, $entity_type, $entity_id) {
$response = new RedirectResponse($base_url, 301);
$response->send();
}
return $response;
}

}

0 comments on commit 2052aaa

Please sign in to comment.