You are here

public function purl_subdomain::rewrite in Persistent URL 6

Same name and namespace in other branches
  1. 7 includes/purl_subdomain.inc \purl_subdomain::rewrite()

Responsible for rewriting outgoing links. Note: it's this functions job to make sure it doesn't alter a link that has already been treated.

This must also check $options['purl']['disabled'] and $options['purl']['remove']. The _purl_skip() method is helpful for this.

Parameters

$path: string, by-reference the path to modify.

$options: See url() docs

$element: The element to add to the path.

Overrides purl_processor::rewrite

File

includes/purl_subdomain.inc, line 46

Class

purl_subdomain
Subdomain prefixing.

Code

public function rewrite(&$path, &$options, $element) {
  $options['absolute'] = TRUE;
  if ($base_url = $this
    ->base_url()) {
    if (!_purl_skip($element, $options)) {
      $base = parse_url($base_url);
      $port = !empty($base['port']) ? ':' . $base['port'] : "";
      $options['base_url'] = "{$base['scheme']}://{$element->value}.{$base['host']}{$port}{$base['path']}";
    }
    else {
      $options['base_url'] = $base_url;
    }
  }
}