Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Classes for converting files between different file formats.

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

Defines 1 class


Class: conversion  - X-Ref

Class representing a conversion currently in progress.

define_properties()   X-Ref
Define properties.

return: array

get_conversions_for_file(stored_file $file, $format)   X-Ref
Fetch all conversions relating to the specified file.

Only conversions which have a valid file are returned.

param: stored_file $file The source file being converted
param: string $format The targetforamt to filter to
return: conversion[]

remove_old_conversion_records()   X-Ref
Remove all old conversion records.


remove_orphan_records()   X-Ref
Remove orphan records.

Records are considered orphans when their source file not longer exists.
In this scenario we do not want to keep the converted file any longer,
in particular to be compliant with privacy laws.

set_sourcefile(stored_file $file)   X-Ref
Set the source file id for the conversion.

param: stored_file $file The file to convert
return: $this

get_sourcefile()   X-Ref
Fetch the source file.

return: stored_file|false The source file

store_destfile_from_path($filepath)   X-Ref
Set the destination file for this conversion.

param: string $filepath The path to the converted file
return: $this

store_destfile_from_string($content)   X-Ref
Set the destination file for this conversion.

param: string $content The content of the converted file
return: $this

get_destfile()   X-Ref
Get the destination file.

return: stored_file|bool Destination file

get_status()   X-Ref
Helper to ensure that the returned status is always an int.

return: int status

get_converter_instance()   X-Ref
Get an instance of the current converter.

return: converter_interface|false current converter instance

set_data($data)   X-Ref
Transform data into a storable format.

param: \stdClass $data The data to be stored
return: $this

get_data()   X-Ref
Transform data into a storable format.

return: \stdClass The stored data

get_file_record()   X-Ref
Return the file record base for use in the files table.

return: array|bool