Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

param: \context        $context    The context to apply
return: content_writer              The 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