public function Resource::versionedUrl in RESTful 7.2
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().
bool $version_string: TRUE to add the version string to the URL. FALSE otherwise.
Return value
string The fully qualified URL.
Overrides ResourceInterface::versionedUrl
See also
url()
6 calls to Resource::versionedUrl()
- Resource::doDelete in src/
Plugin/ resource/ Resource.php - Shorthand method to perform a quick DELETE request.
- Resource::doGet in src/
Plugin/ resource/ Resource.php - Shorthand method to perform a quick GET request.
- Resource::doWrite in src/
Plugin/ resource/ Resource.php - Resource::getUrl in src/
Plugin/ resource/ Resource.php - Helper method; Get the URL of the resource and query strings.
- Resource::view in src/
Plugin/ resource/ Resource.php - Basic implementation for view.
File
- src/
Plugin/ resource/ Resource.php, line 490 - Contains \Drupal\restful\Plugin\resource\Resource.
Class
Namespace
Drupal\restful\Plugin\resourceCode
public function versionedUrl($path = '', $options = array(), $version_string = TRUE) {
// Make the URL absolute by default.
$options += array(
'absolute' => TRUE,
);
$plugin_definition = $this
->getPluginDefinition();
if (!empty($plugin_definition['menuItem'])) {
$url = variable_get('restful_hook_menu_base_path', 'api') . '/';
$url .= $plugin_definition['menuItem'] . '/' . $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_definition['majorVersion'] . '.' . $plugin_definition['minorVersion'];
}
$url .= '/' . $plugin_definition['resource'] . '/' . $path;
return url(rtrim($url, '/'), $options);
}