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.

This file contains the interface required to implmeent a content writer.

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

Defines 1 class


Interface: content_writer  - X-Ref

The interface for a Moodle content writer.

__construct(writer $writer)   X-Ref
Constructor for the content writer.

Note: The writer_factory must be passed.
param: writer          $writer    The factory.

set_context(\context $context)   X-Ref
Set the context for the current item being processed.

return: content_writer
param: \context        $context    The context to use

export_data(array $subcontext, \stdClass $data)   X-Ref
Export the supplied data within the current context, at the supplied subcontext.

return: content_writer
param: array           $subcontext The location within the current context that this data belongs.
param: \stdClass       $data       The data to be exported

export_metadata(array $subcontext, string $name, $value, string $description)   X-Ref
Export metadata about the supplied subcontext.

Metadata consists of a key/value pair and a description of the value.

return: content_writer
param: array           $subcontext The location within the current context that this data belongs.
param: string          $name       The metadata name.
param: string          $value      The metadata value.
param: string          $description    The description of the value.

export_related_data(array $subcontext, $name, $data)   X-Ref
Export a piece of related data.

return: content_writer
param: array           $subcontext The location within the current context that this data belongs.
param: string          $name       The name of the file to be exported.
param: \stdClass       $data       The related data to export.

export_custom_file(array $subcontext, $filename, $filecontent)   X-Ref
Export a piece of data in a custom format.

return: content_writer
param: array           $subcontext The location within the current context that this data belongs.
param: string          $filename   The name of the file to be exported.
param: string          $filecontent    The content to be exported.

rewrite_pluginfile_urls(array $subcontext, $component, $filearea, $itemid, $text)   X-Ref
Prepare a text area by processing pluginfile URLs within it.

return: string                      The processed string
param: array           $subcontext The location within the current context that this data belongs.
param: string          $component  The name of the component that the files belong to.
param: string          $filearea   The filearea within that component.
param: string          $itemid     Which item those files belong to.
param: string          $text       The text to be processed

export_area_files(array $subcontext, $component, $filearea, $itemid)   X-Ref
Export all files within the specified component, filearea, itemid combination.

return: content_writer
param: array           $subcontext The location within the current context that this data belongs.
param: string          $component  The name of the component that the files belong to.
param: string          $filearea   The filearea within that component.
param: string          $itemid     Which item those files belong to.

export_file(array $subcontext, \stored_file $file)   X-Ref
Export the specified file in the target location.

return: content_writer
param: array           $subcontext The location within the current context that this data belongs.
param: \stored_file    $file       The file to be exported.

export_user_preference(string $component, string $key, string $value, string $description)   X-Ref
Export the specified user preference.

return: content_writer
param: string          $component  The name of the component.
param: string          $key        The name of th key to be exported.
param: string          $value      The value of the preference
param: string          $description    A description of the value

finalise_content()   X-Ref
Perform any required finalisation steps and return the location of the finalised export.

return: string