Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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.

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

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

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

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.

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.
return: content_writer

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

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.
return: content_writer

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

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.
return: content_writer

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

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
return: string                      The processed string

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

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.
return: content_writer

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

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

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

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
return: content_writer

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

return: string