You are here

public function Discovery::getSelf in RESTful 7.2

Returns the URL to the endpoint result.

Parameters

DataInterpreterInterface $interpreter: The plugin's data interpreter.

Return value

string The RESTful endpoint URL.

File

src/Plugin/resource/Discovery.php, line 80
Contains \Drupal\restful\Plugin\resource\Discovery

Class

Discovery
Class Discovery @package Drupal\restful_example\Plugin\Resource

Namespace

Drupal\restful\Plugin\resource

Code

public function getSelf(DataInterpreterInterface $interpreter) {
  if ($menu_item = $interpreter
    ->getWrapper()
    ->get('menuItem')) {
    $url = variable_get('restful_hook_menu_base_path', 'api') . '/' . $menu_item;
    return url($url, array(
      'absolute' => TRUE,
    ));
  }
  $base_path = variable_get('restful_hook_menu_base_path', 'api');
  return url($base_path . '/v' . $interpreter
    ->getWrapper()
    ->get('majorVersion') . '.' . $interpreter
    ->getWrapper()
    ->get('minorVersion') . '/' . $interpreter
    ->getWrapper()
    ->get('resource'), array(
    'absolute' => TRUE,
  ));
}