Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
communication_matrix\matrix_client Class Reference
Inheritance diagram for communication_matrix\matrix_client:
communication_matrix\local\spec\v1p1 communication_matrix\local\spec\v1p2 communication_matrix\local\spec\v1p3 communication_matrix\local\spec\v1p4 communication_matrix\local\spec\v1p5 communication_matrix\local\spec\v1p6 communication_matrix\local\spec\v1p7

Public Member Functions

 get_server_url ()
 Get the URL of the server.
 
 get_supported_features ()
 Get a list of the features supported by this client.
 
 get_token ()
 Get the current token in use.
 
 get_version ()
 Get the API version of the current instance.
 
 implements_feature (array|string $feature)
 Determine if the API supports a feature.
 
 meets_version (string $minversion)
 Check if the API version is at least the specified version.
 
 require_feature (array|string $feature)
 Require that the API supports a feature.
 
 require_features (array $features)
 Require that the API supports a list of features.
 
 requires_version (string $minversion)
 Assert that the API version is at least the specified version.
 

Static Public Member Functions

static get_supported_versions ()
 Get the list of supported versions based on the available classes.
 
static instance (string $serverurl, string $accesstoken,)
 Return the versioned instance of the API.
 

Protected Member Functions

 __construct (protected string $serverurl, protected string $accesstoken,)
 Matrix events constructor to get the room id and refresh token usage if required.
 
 execute (command $command,)
 Execute the specified command.
 
 get_client ()
 Helper to fetch the HTTP Client for the instance.
 

Static Protected Member Functions

static get_http_client ()
 Helper to fetch the HTTP Client.
 
static get_version_from_classname (string $classname)
 Normalise an API version from a classname.
 
static query_server_supports (string $serverurl)
 Query the supported versions, and any unstable features, from the server.
 

Static Protected Attributes

string string static http_client null http_client null $client = null
 $serverurl The URL of the home server
 

Constructor & Destructor Documentation

◆ __construct()

communication_matrix\matrix_client::__construct ( protected string $serverurl,
protected string $accesstoken )
protected

Matrix events constructor to get the room id and refresh token usage if required.

Parameters
string$serverurlThe URL of the API server
string$accesstokenThe admin access token

Member Function Documentation

◆ execute()

communication_matrix\matrix_client::execute ( command $command)
protected

Execute the specified command.

Parameters
command$command
Return values
Response

◆ get_client()

communication_matrix\matrix_client::get_client ( )
protected

Helper to fetch the HTTP Client for the instance.

Return values
core\http_client

◆ get_http_client()

static communication_matrix\matrix_client::get_http_client ( )
staticprotected

Helper to fetch the HTTP Client.

Return values
core\http_client

◆ get_server_url()

communication_matrix\matrix_client::get_server_url ( )

Get the URL of the server.

Return values
string

◆ get_supported_features()

communication_matrix\matrix_client::get_supported_features ( )

Get a list of the features supported by this client.

Return values
string[]

◆ get_supported_versions()

static communication_matrix\matrix_client::get_supported_versions ( )
static

Get the list of supported versions based on the available classes.

Return values
array

◆ get_token()

communication_matrix\matrix_client::get_token ( )

Get the current token in use.

Return values
string

◆ get_version()

communication_matrix\matrix_client::get_version ( )

Get the API version of the current instance.

Return values
string

◆ get_version_from_classname()

static communication_matrix\matrix_client::get_version_from_classname ( string $classname)
staticprotected

Normalise an API version from a classname.

Parameters
string$classnameThe short classname, omitting any namespace or file extension
Return values
stringThe normalised version

◆ implements_feature()

communication_matrix\matrix_client::implements_feature ( array|string $feature)

Determine if the API supports a feature.

If an Array is provided, this will return true if any of the specified features is implemented.

Parameters
string[] | string$featureThe feature to check. This is in the form of a namespaced class.
Return values
bool

◆ instance()

static communication_matrix\matrix_client::instance ( string $serverurl,
string $accesstoken )
static

Return the versioned instance of the API.

Parameters
string$serverurlThe URL of the API server
string$accesstokenThe admin access token to use
Return values
matrix_client|null

◆ meets_version()

communication_matrix\matrix_client::meets_version ( string $minversion)

Check if the API version is at least the specified version.

Parameters
string$minversionThe minimum API version required
Return values
bool

◆ query_server_supports()

static communication_matrix\matrix_client::query_server_supports ( string $serverurl)
staticprotected

Query the supported versions, and any unstable features, from the server.

Servers must implement the client versions API described here:

Parameters
string$serverurlThe server base
Return values
null|stdClassThe list of supported versions and a list of enabled unstable features

◆ require_feature()

communication_matrix\matrix_client::require_feature ( array|string $feature)

Require that the API supports a feature.

If an Array is provided, this is treated as a require any of the features.

Parameters
string[] | string$featureThe feature to test
Exceptions
moodle_exception

◆ require_features()

communication_matrix\matrix_client::require_features ( array $features)

Require that the API supports a list of features.

All features specified will be required.

If an array is provided as one of the features, any of the items in the nested array will be required.

Parameters
string[] | array[]$featuresThe list of features required

Here is an example usage: $matrixapi->require_features([

communication_matrix::local::spec::features::create_room::class,
[
    communication_matrix::local::spec::features::get_room_info_v1::class,
    communication_matrix::local::spec::features::get_room_info_v2::class,
]

])

◆ requires_version()

communication_matrix\matrix_client::requires_version ( string $minversion)

Assert that the API version is at least the specified version.

Parameters
string$minversionThe minimum API version required
Exceptions
Exception

Member Data Documentation

◆ $client

string string static http_client null http_client null communication_matrix\matrix_client::$client = null
staticprotected

$serverurl The URL of the home server

$accesstoken The access token of the matrix server The client to use


The documentation for this class was generated from the following file: