Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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.