public function RestfulBase::versionedUrl in RESTful 7
Gets a resource URL based on the current version.
Parameters
string $path: The path for the resource
array $options: Array of options as in url().
boolean $version_string: TRUE to add the version string to the URL. FALSE otherwise.
Return value
string The fully qualified URL.
See also
url().
3 calls to RestfulBase::versionedUrl()
- RestfulBase::getUrl in plugins/
restful/ RestfulBase.php - Helper method; Get the URL of the resource and query strings.
- RestfulEntityBase::getEntityIdByFieldId in plugins/
restful/ RestfulEntityBase.php - Get the entity ID based on the ID provided in the request.
- RestfulEntityBase::getEntitySelf in plugins/
restful/ RestfulEntityBase.php - Get the "self" url.
File
- plugins/
restful/ RestfulBase.php, line 1540 - Contains RestfulBase.
Class
- RestfulBase
- Class \RestfulBase
Code
public function versionedUrl($path = '', $options = array(), $version_string = TRUE) {
// Make the URL absolute by default.
$options += array(
'absolute' => TRUE,
);
$plugin = $this
->getPlugin();
if (!empty($plugin['menu_item'])) {
$url = $plugin['menu_item'] . '/' . $path;
return url(rtrim($url, '/'), $options);
}
$base_path = variable_get('restful_hook_menu_base_path', 'api');
$url = $base_path;
if ($version_string) {
$url .= '/v' . $plugin['major_version'] . '.' . $plugin['minor_version'];
}
$url .= '/' . $plugin['resource'] . '/' . $path;
return url(rtrim($url, '/'), $options);
}