You are here

public function ResourceManager::negotiate in RESTful 7.2

Gets the resource plugin based on the information in the request object.

Return value

ResourceInterface The resource plugin instance.

Throws

ServerConfigurationException If the plugin could not be found.

Overrides ResourceManagerInterface::negotiate

File

src/Resource/ResourceManager.php, line 163
Contains \Drupal\restful\Resource\ResourceManager.

Class

ResourceManager

Namespace

Drupal\restful\Resource

Code

public function negotiate() {
  $version = $this
    ->getVersionFromRequest();
  list($resource_name, ) = static::getPageArguments($this->request
    ->getPath(FALSE));
  try {
    $resource = $this
      ->getPlugin($resource_name . PluginBase::DERIVATIVE_SEPARATOR . $version[0] . '.' . $version[1]);
    return $resource
      ->isEnabled() ? $resource : NULL;
  } catch (PluginNotFoundException $e) {
    throw new ServerConfigurationException($e
      ->getMessage());
  }
}