function classified_url_outbound_alter in Classified Ads 7.3
Implements hook_url_outbound_alter().
When reporting broken taxonomy links, we want stack [2], because:
- [0] is module.inc#drupal_alter() calling classified_url_outbound_alter()
- [1] is common.inc#url() calling drupal_alter('url_outbound')
File
- ./
classified.module, line 1759 - A pure D7 classified ads module inspired by the ed_classified module.
Code
function classified_url_outbound_alter(&$path, &$options, $original_path) {
if (preg_match('!^taxonomy/term/(\\d+)$!', $path, $matches)) {
$term = isset($options['entity']->vocabulary_machine_name) ? $options['entity'] : taxonomy_term_load($matches[1]);
if (!$term) {
$stack = debug_backtrace();
watchdog('classified', 'Outbound taxonomy URL to nonexistent term: %path, from %emitter', array(
'%path' => $path,
'%emitter' => print_r($stack[2], TRUE),
), WATCHDOG_NOTICE);
}
elseif (isset($term->vocabulary_machine_name) && $term->vocabulary_machine_name == 'classified_categories') {
$path = 'classified/' . $matches[1];
$options['alias'] = $path;
}
}
}