You are here

function path_alias_xt_init in Extended Path Aliases 7

Same name and namespace in other branches
  1. 6 path_alias_xt.module \path_alias_xt_init()

Implements hook_init().

File

./path_alias_xt.module, line 220
Extended Path Aliases.

Code

function path_alias_xt_init() {

  // Purists look away...
  // There is no suitable hook to override core's drupal_get_path_alias()
  // behaviour. So we either take on the impossible task of rewriting all
  // modules that call it, or we redefine its body to make a simple call back to
  // this module. We can do this programmatically by taking advantage of the
  // PECL runkit extension. The runkit needs to be compiled and placed in the
  // /extensions (or /ext) directory pointed to by the extension_dir directive
  // in php.ini.
  // Dynamically load the runkit. This may not be supported on multi-threaded
  // web servers.
  // If the statement below produces an error on your system, comment it out and
  // make sure that you have "extension=runkit.so" in your php.ini.
  // Alternatively, apply the simple edit to includes/path.inc as described in
  // the README file.
  // Dl('runkit.so');.
  if (function_exists('runkit_function_redefine')) {
    $args = '$path=NULL, $path_language=NULL';
    $body = 'return path_alias_xt_get_path_alias($path, $path_language);';
    runkit_function_redefine('drupal_get_path_alias', $args, $body);
  }
}