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.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]

Contains the remote_resource class definition.

Copyright: 2020 Jake Dallimore <jrhdallimore@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 169 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

remote_resource:: (9 methods):
  __construct()
  get_url()
  get_name()
  get_metadata()
  get_description()
  get_extension()
  get_download_size()
  download_to_requestdir()
  get_resource_info()


Class: remote_resource  - X-Ref

The remote_resource class.

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

__construct(\curl $curl, url $url, \stdClass $metadata)   X-Ref
The remote_resource constructor.

param: \curl $curl a curl object for HTTP requests.
param: url $url the URL of the remote resource.
param: \stdClass $metadata resource metadata such as name, summary, license, etc.

get_url()   X-Ref
Return the URL for this remote resource.

return: url the url object.

get_name()   X-Ref
Get the name of the file as taken from the metadata.


get_metadata()   X-Ref
Get the resource metadata.

return: \stdClass the metadata.

get_description()   X-Ref
Get the description of the resource as taken from the metadata.

return: string

get_extension()   X-Ref
Return the extension of the file, if found.

return: string the extension of the file, if found.

get_download_size()   X-Ref
Returns the file size of the remote file, in bytes, or null if it cannot be determined.

return: int|null the content length, if able to be determined, otherwise null.

download_to_requestdir()   X-Ref
Download the remote resource to a local requestdir, returning the path and name of the resulting file.

return: array an array containing filepath adn filename, e.g. [filepath, filename].

get_resource_info()   X-Ref
Fetches information about the remote resource via a HEAD request.