You are here

public function Plugins::execute in JSON-RPC 2.x

Same name and namespace in other branches
  1. 8 modules/jsonrpc_core/src/Plugin/jsonrpc/Method/Plugins.php \Drupal\jsonrpc_core\Plugin\jsonrpc\Method\Plugins::execute()

Throws

\Drupal\jsonrpc\Exception\JsonRpcException

Overrides ExecutableWithParamsInterface::execute

File

modules/jsonrpc_core/src/Plugin/jsonrpc/Method/Plugins.php, line 80

Class

Plugins
Lists the plugin definitions of a given type.

Namespace

Drupal\jsonrpc_core\Plugin\jsonrpc\Method

Code

public function execute(ParameterBag $params) {
  $pager = $params
    ->get('page');
  $definitions = $this->pluginManager
    ->getDefinitions();
  foreach ($definitions as $definition) {
    if (!is_array($definition)) {
      throw JsonRpcException::fromError(Error::invalidParams('Object-based plugin definitions are not yet supported.'));
    }
  }
  if (!$pager) {
    return $definitions;
  }
  return array_slice($definitions, $pager['offset'], $pager['limit']);
}