$entity) { $path = $callback($entity); $aliases = _uuid_path_url_alias_load($path['path']); // Ignore local IDs. foreach ($aliases as &$alias) { unset($alias->pid); unset($alias->source); } $entities[$id]->url_alias = $aliases; } } /** * Saves the received url aliases. */ function _uuid_path_save_url_aliases(&$entity, $entity_type) { $info = entity_get_info($entity_type); // We only care when there is a url callback. if (!isset($info['uri callback'])) { return FALSE; } $callback = $info['uri callback']; $uri = $callback($entity); $path = $uri['path']; // Delete existing aliases. path_delete(array('source' => $path)); // Continue if aliases are present. if (empty($entity->url_alias)) { return FALSE; } foreach ($entity->url_alias as $alias) { $entry = (array) $alias; $entry['source'] = $path; path_save($entry); } } /** * Loads all aliases associated with a path. * * @param string $path * The source path to look up. * * @return array * Array of paths or NULL if none found. */ function _uuid_path_url_alias_load($path) { return db_select('url_alias') ->condition('source', $path) ->fields('url_alias') ->execute() ->fetchAll(PDO::FETCH_OBJ); }