1 redirect.api.php hook_redirect_prepare(Redirect $redirect, array $values)

Act on a redirect object about to be shown on the add/edit form.

This hook is invoked from the Redirect object constructor in Redirect::__construct().


Redirect $redirect: A newly initialized redirect object. Likely to be shown on the form for adding or editing a redirect.

array $values: The default values for the Redirect from the database if editing an existing Redirect.

Related topics


core/modules/redirect/redirect.api.php, line 164
Hooks provided by the Redirect module.


function hook_redirect_prepare(Redirect $redirect, array $values) {
  // Change the default type to be a 302 temporary redirect instead of a 301
  // permanent redirect.
  if (empty($values['type'])) {
    $redirect->type = 302;