Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250706) (a6b17d8f6bd)
core\router\route Class Reference

Public Member Functions

 __construct (public string readonly string $title='', public string readonly string $description='', public string readonly string $summary='', public array< string > readonly ?array $security=null, public string|null ?string $path=null, null|array|string $method=null, protected parameter[] readonly array $pathtypes=[], protected parameter[] readonly array $queryparams=[], protected parameter[] readonly array $headerparams=[], public null|request_body readonly ?request_body $requestbody=null, protected response[] readonly array $responses=[], public bool readonly bool $deprecated=false, public string[] readonly array $tags=[], public bool readonly bool $cookies=true, public bool readonly bool $abortafterconfig=false, public null|array readonly ?require_login $requirelogin=null, public string[] readonly ?array $scopes=null,... $extra,)
 Constructor for a new Moodle route.
 
 get_header_parameters ()
 Get the list of path parameters, including any from the parent.
 
 get_methods (?array $default=null)
 Get the list of HTTP methods associated with this route.
 
 get_path ()
 Get the fully-qualified path for this route relative to root.
 
 get_path_parameters ()
 Get the list of path parameters, including any from the parent.
 
 get_query_parameters ()
 Get the list of path parameters, including any from the parent.
 
 get_request_body ()
 Get the request body for this route.
 
 get_response_with_status_code (int $statuscode)
 Get the response with the specified response code.
 
 get_responses ()
 Get all responses.
 
 has_any_validatable_parameter ()
 Whether this route expects any validatable parameters.
 
 has_request_body ()
 Whether this route expects a request body.
 
 set_parent (route $parent)
 Set the parent route, usually a Class-level route.
 

Protected Attributes

string[] null array $method = null
 The list of HTTP Methods.
 
route null readonly route $parentroute
 The parent route, if relevant.
 

Constructor & Destructor Documentation

◆ __construct()

core\router\route::__construct ( public string readonly string $title = '',
public string readonly string $description = '',
public string readonly string $summary = '',
public array< string > readonly ?array $security = null,
public string|null ?string $path = null,
null|array|string $method = null,
protected parameter[]readonly array $pathtypes = [],
protected parameter[]readonly array $queryparams = [],
protected parameter[]readonly array $headerparams = [],
public null|request_body readonly ?request_body $requestbody = null,
protected response[]readonly array $responses = [],
public bool readonly bool $deprecated = false,
public string[]readonly array $tags = [],
public bool readonly bool $cookies = true,
public bool readonly bool $abortafterconfig = false,
public null|array readonly ?require_login $requirelogin = null,
public string[]readonly ?array $scopes = null,
... )

Constructor for a new Moodle route.

Parameters
string$titleA title to briefly describe the route (not translated)
string$descriptionA verbose explanation of the operation behavior (not translated)
string$summaryA short summary of what the operation does (not translated)
null | string[]$securityA list of security mechanisms
null | string$pathThe path to match
null | array | string$methodThe method, or methods, supported
parameter[]$pathtypesValidators for the path arguments
parameter[]$queryparamsValidators for the path arguments
parameter[]$headerparamsValidators for the path arguments
request_body | null$requestbodyValidators for the path arguments
response[]$responsesA list of possible response types
bool$deprecatedWhether this endpoint is deprecated
string[]$tagsA list of tags
bool$cookiesWhether this request requires cookies
bool$abortafterconfigWhether to abort after configuration
mixed[]...$extra Any additional arguments not yet supported in this version of Moodle
Exceptions
coding_exception
Parameters
$titleA title to briefly describe the route (not translated)
$descriptionA verbose explanation of the operation behavior (not translated)
$summaryA short summary of what the operation does (not translated)
$securityA list of security mechanisms
$pathThe path to the route.

This is relative to the parent route, if one exists. A route must be set on one, or both, of the class and method level routes.

Parameters
$pathtypesA list of param types for path arguments
$queryparamsA list of query parameters with matching types
$headerparamsA list of header parameters
$requestbodyA list of parameters found in the body
$responsesA list of possible response types
$deprecatedWhether this endpoint is deprecated
$tagsA list of tags
$cookiesWhether this request may use cookies
$abortafterconfigWhether to abort after configuration
$requireloginWhether to require login or not
$scopesThe list of scopes required to access this page

Member Function Documentation

◆ get_header_parameters()

core\router\route::get_header_parameters ( )

Get the list of path parameters, including any from the parent.

Return values
array

◆ get_methods()

core\router\route::get_methods ( ?array $default = null)

Get the list of HTTP methods associated with this route.

Parameters
null | string[]$defaultThe default methods to use if none are set
Return values
null|string[]

◆ get_path()

core\router\route::get_path ( )

Get the fully-qualified path for this route relative to root.

This includes the path of any parent route.

Return values
string

◆ get_path_parameters()

core\router\route::get_path_parameters ( )

Get the list of path parameters, including any from the parent.

Return values
array

◆ get_query_parameters()

core\router\route::get_query_parameters ( )

Get the list of path parameters, including any from the parent.

Return values
array

◆ get_request_body()

core\router\route::get_request_body ( )

Get the request body for this route.

Return values
request_body|null

◆ get_response_with_status_code()

core\router\route::get_response_with_status_code ( int $statuscode)

Get the response with the specified response code.

Parameters
int$statuscode
Return values
response|null

◆ get_responses()

core\router\route::get_responses ( )

Get all responses.

Return values
response[]

◆ has_any_validatable_parameter()

core\router\route::has_any_validatable_parameter ( )

Whether this route expects any validatable parameters.

That is, any parameter in the path, query params, or the request body.

Return values
bool

◆ has_request_body()

core\router\route::has_request_body ( )

Whether this route expects a request body.

Return values
bool

◆ set_parent()

core\router\route::set_parent ( route $parent)

Set the parent route, usually a Class-level route.

Parameters
route$parent
Return values
self

Member Data Documentation

◆ $parentroute

route null readonly route core\router\route::$parentroute
protected

The parent route, if relevant.

A method-level route may have a class-level route as a parent. The two are combined to provide a fully-qualified path.


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