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 402] [Versions 400 and 403]

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

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

Defines 1 class

writer:: (7 methods):
  __construct()
  get_writer_instance()
  setup_real_writer_instance()
  instance()
  reset()
  with_context()
  export_user_preference()


Class: writer  - X-Ref

The writer factory class used to fetch and work with the content_writer.

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

Protected to prevent direct instantiation.

get_writer_instance()   X-Ref
Singleton to return or create and return a copy of a content_writer.

return: content_writer

setup_real_writer_instance()   X-Ref
Create a real content_writer for use by PHPUnit tests,
where a mock writer will not suffice.

return: content_writer

instance()   X-Ref
Return an instance of


reset()   X-Ref
Reset the writer and content_writer.


with_context(\context $context)   X-Ref
Provide an instance of the writer with the specified context applied.

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

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