Details
-
Type: Extension Review Request
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.7.30
-
Fix Version/s: 5.0.0
-
Component/s: CiviCRM API
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:Developer Doc
-
Funding Source:Contributed Code
-
Verified?:No
Description
Proposal to add a hook into the redirect function. This is consistent with Drupal which has a redirect hook.
The specific use case is that the postProcess hook of the Merge page redirects to a listing page. This listing page only calls a hook (pageRun) AFTER the various processing has been done. In order to alter a parameter for the page I think the most logical place is when the redirect is being processed
```
/**
- Redirect to another URL.
* - @param string $url
- The URL to provide to the browser via the Location header.
*/
public static function redirect($url = NULL) {
if (!$url) {
$url = self::url('civicrm/dashboard', 'reset=1');
}
// replace the & characters with &
// this is kinda hackish but not sure how to do it right
$url = str_replace('&', '&', $url);
// If we are in a json context, respond appropriately
if (CRM_Utils_Array::value('snippet', $_GET) === 'json') {
CRM_Core_Page_AJAX::returnJsonResponse(array(
'status' => 'redirect',
'userContext' => $url,
));
}
```
self::setHttpHeader('Location', $url);
self::civiExit();
}