Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

(no description)

File Size: 189 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: command  - X-Ref

A command to be sent to the Matrix server.

This class is a wrapper around the PSR-7 Request Interface implementation provided by Guzzle.

It takes a set of common parameters and configurations and turns them into a Request that can be called against a live server.

__construct(protected matrix_client $client,string $method,string $endpoint,protected array $params = [],protected array $query = [],protected bool $ignorehttperrors = false,protected bool $requireauthorization = true,protected bool $sendasjson = true,)   X-Ref
Create a new Command.

param: matrix_client $client The URL for this method
param: string $method (GET|POST|PUT|DELETE)
param: string $endpoint The URL
param: array $params Any parameters to pass
param: array $query Any query parameters to set on the URL
param: bool $ignorehttperrors Whether to ignore HTTP Errors
param: bool $requireauthorization Whether authorization is required for this request
param: bool $sendasjson Whether to send params as JSON

get_url(string $endpoint)   X-Ref
Get the URL of the endpoint on the server.

param: string $endpoint
return: string

get_all_params()   X-Ref
Get all parameters, including those set in the URL.

return: array

get_remaining_params()   X-Ref
Get the parameters provided to the command which are not used in the URL.

These are typically passed to the server as query or body parameters instead.

return: array

get_options()   X-Ref
Get the Guzzle options to pass into the request.

return: array

require_authorization()   X-Ref
Whether authorization is required.

Based on the 'authorization' attribute set in a raw command.

return: bool

should_ignore_http_errors()   X-Ref
Whether to ignore http errors on the response.

Based on the 'ignore_http_errors' attribute set in a raw command.

return: bool

should_send_params_as_json()   X-Ref
Whether to send remaining parameters as JSON.

return: bool