You are here

public function ResourceManager::getPlugin in RESTful 7.2

Get a resource plugin instance by instance ID.

Parameters

string $instance_id: The instance ID.

RequestInterface $request: The request object.

Return value

ResourceInterface The plugin.

Throws

PluginNotFoundException If the plugin instance cannot be found.

Overrides ResourceManagerInterface::getPlugin

1 call to ResourceManager::getPlugin()
ResourceManager::negotiate in src/Resource/ResourceManager.php
Gets the resource plugin based on the information in the request object.

File

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

Class

ResourceManager

Namespace

Drupal\restful\Resource

Code

public function getPlugin($instance_id, RequestInterface $request = NULL) {

  /* @var ResourceInterface $plugin */
  if (!($plugin = $this->plugins
    ->get($instance_id))) {
    return NULL;
  }
  if ($request) {
    $plugin
      ->setRequest($request);
  }
  return $plugin;
}