5 * Hooks provided by the Redirect module.
9 * @defgroup redirect_api_hooks Redirect API Hooks
11 * During redirect operations (create, update, view, delete, etc.), there are
12 * several sets of hooks that get invoked to allow modules to modify the
14 * - All-module hooks: Generic hooks for "redirect" operations. These are
15 * always invoked on all modules.
16 * - Entity hooks: Generic hooks for "entity" operations. These are always
17 * invoked on all modules.
19 * Here is a list of the redirect and entity hooks that are invoked, and other
20 * steps that take place during redirect operations:
21 * - Creating a new redirect (calling redirect_save() on a new redirect):
22 * - hook_redirect_presave() (all)
23 * - Redirect written to the database
24 * - hook_redirect_insert() (all)
25 * - hook_entity_insert() (all)
26 * - Updating an existing redirect (calling redirect_save() on an existing redirect):
27 * - hook_redirect_presave() (all)
28 * - Redirect written to the database
29 * - hook_redirect_update() (all)
30 * - hook_entity_update() (all)
31 * - Loading a redirect (calling redirect_load(), redirect_load_multiple(), or
32 * entity_load() with $entity_type of 'redirect'):
33 * - Redirect information is read from database.
34 * - hook_entity_load() (all)
35 * - hook_redirect_load() (all)
36 * - Deleting a redirect (calling redirect_delete() or redirect_delete_multiple()):
37 * - Redirect is loaded (see Loading section above)
38 * - Redirect information is deleted from database
39 * - hook_redirect_delete() (all)
40 * - hook_entity_delete() (all)
41 * - Preparing a redirect for editing (note that if it's
42 * an existing redirect, it will already be loaded; see the Loading section
44 * - hook_redirect_prepare() (all)
45 * - Validating a redirect during editing form submit (calling
46 * redirect_form_validate()):
47 * - hook_redirect_validate() (all)
57 * Act on redirects being loaded from the database.
59 * This hook is invoked during redirect loading, which is handled by
60 * entity_load(), via classes RedirectController and
61 * DrupalDefaultEntityController. After the redirect information is read from
62 * the database or the entity cache, hook_entity_load() is invoked on all
63 * implementing modules, and then hook_redirect_load() is invoked on all
64 * implementing modules.
66 * This hook should only be used to add information that is not in the redirect
67 * table, not to replace information that is in that table (which could
68 * interfere with the entity cache). For performance reasons, information for
69 * all available redirects should be loaded in a single query where possible.
71 * The $types parameter allows for your module to have an early return (for
72 * efficiency) if your module only supports certain redirect types.
75 * An array of the redirects being loaded, keyed by rid.
77 * An array containing the types of the redirects.
79 * @ingroup redirect_api_hooks
81 function hook_redirect_load(array &$redirects, $types) {
86 * Alter the list of redirects matching a certain source.
89 * An array of redirect objects.
91 * The source request path.
93 * An array with the following key/value pairs:
94 * - language: The language code of the source request.
95 * - query: An array of the source request query string.
97 * @see redirect_load_by_source()
98 * @ingroup redirect_api_hooks
100 function hook_redirect_load_by_source_alter(array &$redirects, $source, array $context) {
101 foreach ($redirects as $rid => $redirect) {
102 if ($redirect->source !== $source) {
103 // If the redirects to do not exactly match $source (e.g. case
104 // insensitive matches), then remove them from the results.
105 unset($redirects[$rid]);
111 * Act on a redirect object about to be shown on the add/edit form.
113 * This hook is invoked from redirect_create().
116 * The redirect that is about to be shown on the add/edit form.
118 * @ingroup redirect_api_hooks
120 function hook_redirect_prepare($redirect) {
125 * Act on a redirect being redirected.
127 * This hook is invoked from redirect_redirect() before the redirect callback
131 * The redirect that is being used for the redirect.
133 * @see redirect_redirect()
134 * @see drupal_page_is_cacheable()
135 * @ingroup redirect_api_hooks
137 function hook_redirect_alter($redirect) {
141 * @} End of "addtogroup hooks".