You are here

public function JsonRpcMethodManager::alterDefinitions in JSON-RPC 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/JsonRpcMethodManager.php \Drupal\jsonrpc\Plugin\JsonRpcMethodManager::alterDefinitions()

Invokes the hook to alter the definitions if the alter hook is set.

Parameters

$definitions: The discovered plugin definitions.

Overrides DefaultPluginManager::alterDefinitions

File

src/Plugin/JsonRpcMethodManager.php, line 40

Class

JsonRpcMethodManager
Provides the JsonRpcMethod plugin manager.

Namespace

Drupal\jsonrpc\Plugin

Code

public function alterDefinitions(&$definitions) {

  /* @var \Drupal\jsonrpc\Annotation\JsonRpcMethod $method */
  foreach ($definitions as &$method) {
    $this
      ->assertValidJsonRpcMethodPlugin($method);
    if (isset($method->params)) {
      foreach ($method->params as $key => &$param) {
        $param
          ->setId($key);
      }
    }
    $class = $method
      ->getClass();
    $output_schema = $class::outputSchema();
    $method->output = $output_schema;
  }
  parent::alterDefinitions($definitions);
}