Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

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

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.

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

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.

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

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

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

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.

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

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