You are here

function purl_generate_rewrite_elements in Persistent URL 6

Same name and namespace in other branches
  1. 7 purl.module \purl_generate_rewrite_elements()

Generate a purl_path_element for provider

Parameters

$item: An array with the keys: "provider" & "id"

Return value

a purl_path_element object.

1 call to purl_generate_rewrite_elements()
purl_url_outbound_alter in ./purl.module
Implementation of hook_url_outbound_alter().

File

./purl.module, line 365

Code

function purl_generate_rewrite_elements($item) {
  $method = variable_get('purl_method_' . $item['provider'], 'path');
  $processor = purl_get_processor($method);
  $local_modifiers = purl_modifiers($method);
  $provider = $id = NULL;
  foreach ($local_modifiers as $k => $v) {
    if ($v['provider'] == $item['provider']) {

      // If an id is NULL it simply indicates that the method doesn't need
      // to cache them, for example PURL_PAIR.
      if ($v['id'] === null || $v['id'] == $item['id']) {
        $provider = $item['provider'];
        $id = $item['id'];
        break;
      }
    }
  }
  if (isset($provider) && isset($id)) {
    return new purl_path_element($processor, $k, $provider, $id);
  }
}