Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

The definition of an item which can be exported.

Copyright: 2020 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 202 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

exportable_stored_file:: (5 methods):
  __construct()
  create_from_area_params()
  add_to_archive()
  get_filepath_for_file()
  get_pluginfile_url_for_stored_file()


Class: exportable_stored_file  - X-Ref

An object used to represent content which can be served.

__construct(context $context,string $component,string $uservisiblename,stored_file $file,?int $pluginfileitemid = null,string $folderpath = '')   X-Ref
Create a new exportable_item instance.

If no filearea or itemid  is specified the no attempt will be made to export files.

param: context $context The context that this content belongs to
param: string $component
param: string $uservisiblename The name displayed to the user when filtering
param: stored_file $file
param: null|int $pluginfileitemid The itemid as used in the pluginfile URL.
param: string $folderpath Any sub-directory to place files in

create_from_area_params(context $context,string $component,string $filearea,?int $itemid,?int $pluginfileitemid = null,string $folderpath = '')   X-Ref
Create a set of exportable_items from a set of area paramaters as passed to get_areas_files().

If no filearea or itemid  is specified the no attempt will be made to export files.

param: context $context The context that this content belongs to
param: string $component
param: string $filearea
param: null|int $itemid
param: null|int $pluginfileitemid The itemid as used in the pluginfile URL.
param: string $folderpath Any sub-directory to place files in
return: array

add_to_archive(zipwriter $archive)   X-Ref
Add the content to the archive.

param: zipwriter $archive

get_filepath_for_file()   X-Ref
Get the filepath for the specified stored_file.

return: string

get_pluginfile_url_for_stored_file(stored_file $file, ?int $pluginfileitemid)   X-Ref
Get the pluginfile URL for a stored file.

Note: The itemid in the pluginfile may be omitted in some URLs, despite an itemid being present in the database.
Equally, the itemid in the URL may not match the itemid in the files table.

The pluginfileitemid argument provided to this function is the variant in the URL, and not the one in the files
table.

param: stored_file $file The file whose link will be generated
param: null|int $pluginfileitemid The itemid of the file in pluginfile URL.