You are here

protected function JsonRpcMethodManager::assertValidJsonRpcMethodPlugin in JSON-RPC 2.x

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

Asserts that the plugin class is valid.

Parameters

\Drupal\jsonrpc\MethodInterface $method: The JSON-RPC method definition.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to JsonRpcMethodManager::assertValidJsonRpcMethodPlugin()
JsonRpcMethodManager::alterDefinitions in src/Plugin/JsonRpcMethodManager.php
Invokes the hook to alter the definitions if the alter hook is set.

File

src/Plugin/JsonRpcMethodManager.php, line 64

Class

JsonRpcMethodManager
Provides the JsonRpcMethod plugin manager.

Namespace

Drupal\jsonrpc\Plugin

Code

protected function assertValidJsonRpcMethodPlugin(MethodInterface $method) {
  foreach ($method->params as $param) {
    if (!$param->factory && !$param->schema) {
      throw new InvalidPluginDefinitionException($method
        ->id(), "Every JsonRpcParameterDefinition must define either a factory or a schema.");
    }
    if ($param->factory && !is_subclass_of($param->factory, ParameterFactoryInterface::class)) {
      throw new InvalidPluginDefinitionException($method
        ->id(), "Parameter factories must implement ParameterFactoryInterface.");
    }
  }
}