Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tool_moodlenet\local\remote_resource Class Reference

The remote_resource class. More...

Public Member Functions

 __construct (\curl $curl, url $url, stdClass $metadata)
 The remote_resource constructor. More...
 
 download_to_requestdir ()
 Download the remote resource to a local requestdir, returning the path and name of the resulting file. More...
 
 get_description ()
 Get the description of the resource as taken from the metadata. More...
 
 get_download_size ()
 Returns the file size of the remote file, in bytes, or null if it cannot be determined. More...
 
 get_extension ()
 Return the extension of the file, if found. More...
 
 get_metadata ()
 Get the resource metadata. More...
 
 get_name ()
 Get the name of the file as taken from the metadata.
 
 get_url ()
 Return the URL for this remote resource. More...
 

Protected Member Functions

 get_resource_info ()
 Fetches information about the remote resource via a HEAD request. More...
 

Protected Attributes

curl $curl
 $curl the curl http helper.
 
string $extension
 $extension the file extension of this remote file.
 
string $filename
 $filename the name of this remote file.
 
array $headinfo = []
 $headinfo the array of information for the most recent HEAD request.
 
stdClass $metadata
 $metadata information about the resource.
 
url $url
 $url the url to the remote resource.
 

Detailed Description

The remote_resource class.

Objects of type remote_resource provide a means of interacting with resources over HTTP.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tool_moodlenet\local\remote_resource::__construct ( \curl  $curl,
url  $url,
stdClass  $metadata 
)

The remote_resource constructor.

Parameters
curl$curla curl object for HTTP requests.
url$urlthe URL of the remote resource.
stdClass$metadataresource metadata such as name, summary, license, etc.

Member Function Documentation

◆ download_to_requestdir()

tool_moodlenet\local\remote_resource::download_to_requestdir ( )

Download the remote resource to a local requestdir, returning the path and name of the resulting file.

Return values
arrayan array containing filepath adn filename, e.g. [filepath, filename].
Exceptions
moodle_exceptionif the file cannot be downloaded.

◆ get_description()

tool_moodlenet\local\remote_resource::get_description ( )

Get the description of the resource as taken from the metadata.

Return values
string

◆ get_download_size()

tool_moodlenet\local\remote_resource::get_download_size ( )

Returns the file size of the remote file, in bytes, or null if it cannot be determined.

Return values
int|nullthe content length, if able to be determined, otherwise null.

◆ get_extension()

tool_moodlenet\local\remote_resource::get_extension ( )

Return the extension of the file, if found.

Return values
stringthe extension of the file, if found.

◆ get_metadata()

tool_moodlenet\local\remote_resource::get_metadata ( )

Get the resource metadata.

Return values
stdClassthe metadata.

◆ get_resource_info()

tool_moodlenet\local\remote_resource::get_resource_info ( )
protected

Fetches information about the remote resource via a HEAD request.

Exceptions
coding_exceptionif any connection problems occur.

◆ get_url()

tool_moodlenet\local\remote_resource::get_url ( )

Return the URL for this remote resource.

Return values
urlthe url object.

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