Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
An implementation of the content_writer for use in unit tests. More...
Public Member Functions | |
__construct (\core_privacy\local\request\writer $writer) | |
Constructor for the content writer. | |
export_area_files (array $subcontext, $component, $filearea, $itemid) | |
Export all files within the specified component, filearea, itemid combination. | |
export_custom_file (array $subcontext, $filename, $filecontent) | |
Export a piece of data in a custom format. | |
export_data (array $subcontext, stdClass $data) | |
Export the supplied data within the current context, at the supplied subcontext. | |
export_file (array $subcontext, stored_file $file) | |
Export the specified file in the target location. | |
export_metadata (array $subcontext, string $key, $value, string $description) | |
Export metadata about the supplied subcontext. | |
export_related_data (array $subcontext, $name, $data) | |
Export a piece of related data. | |
export_user_preference (string $component, string $key, string $value, string $description) | |
Export the specified user preference. | |
finalise_content () | |
Perform any required finalisation steps and return the location of the finalised export. | |
get_all_metadata (array $subcontext=[]) | |
Get all metadata within the subcontext. | |
get_current_context () | |
Return the current context. | |
get_custom_file (array $subcontext=[], $filename=null) | |
Get the specified custom file within the subcontext. | |
get_data (array $subcontext=[]) | |
Get all data within the subcontext. | |
get_files (array $subcontext=[]) | |
Get all files in the specfied subcontext. | |
get_metadata (array $subcontext, $key, $valueonly=true) | |
Get the specified metadata within the subcontext. | |
get_related_data (array $subcontext=[], $filename=null) | |
Get all data within the subcontext. | |
get_user_context_preferences (string $component) | |
Get all user preferences for the specified component. | |
get_user_preferences (string $component) | |
Get all user preferences for the specified component. | |
has_any_data ($subcontext=[]) | |
Whether any data has been exported at all within the current context. | |
has_any_data_in_any_context () | |
Whether any data has been exported for any context. | |
rewrite_pluginfile_urls (array $subcontext, $component, $filearea, $itemid, $text) | |
Prepare a text area by processing pluginfile URLs within it. | |
set_context (\context $context) | |
Set the context for the current item being processed. | |
Protected Member Functions | |
fetch_data_root ($base, $subcontext) | |
Fetch the data region of the specified root. | |
fetch_root ($base, $subcontext, $temporarycontextid=null) | |
Fetch the entire root record at the specified location type, creating it if required. | |
An implementation of the content_writer for use in unit tests.
This implementation does not export any data but instead stores it in structures within the instance which can be easily queried for use during unit tests.
core_privacy\tests\request\content_writer::__construct | ( | \core_privacy\local\request\writer | $writer | ) |
Constructor for the content writer.
Note: The writer_factory must be passed.
core_privacy\local\request\writer | $writer | The writer factory. |
core_privacy\tests\request\content_writer::export_area_files | ( | array | $subcontext, |
$component, | |||
$filearea, | |||
$itemid ) |
Export all files within the specified component, filearea, itemid combination.
array | $subcontext | The location within the current context that this data belongs. |
string | $component | The name of the component that the files belong to. |
string | $filearea | The filearea within that component. |
string | $itemid | Which item those files belong to. |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::export_custom_file | ( | array | $subcontext, |
$filename, | |||
$filecontent ) |
Export a piece of data in a custom format.
array | $subcontext | The location within the current context that this data belongs. |
string | $filename | The name of the file to be exported. |
string | $filecontent | The content to be exported. |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::export_data | ( | array | $subcontext, |
stdClass | $data ) |
Export the supplied data within the current context, at the supplied subcontext.
array | $subcontext | The location within the current context that this data belongs. |
stdClass | $data | The data to be exported |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::export_file | ( | array | $subcontext, |
stored_file | $file ) |
Export the specified file in the target location.
array | $subcontext | The location within the current context that this data belongs. |
stored_file | $file | The file to be exported. |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::export_metadata | ( | array | $subcontext, |
string | $key, | ||
$value, | |||
string | $description ) |
Export metadata about the supplied subcontext.
Metadata consists of a key/value pair and a description of the value.
array | $subcontext | The location within the current context that this data belongs. |
string | $key | The metadata name. |
string | $value | The metadata value. |
string | $description | The description of the value. |
$this |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::export_related_data | ( | array | $subcontext, |
$name, | |||
$data ) |
Export a piece of related data.
array | $subcontext | The location within the current context that this data belongs. |
string | $name | The name of the file to be exported. |
stdClass | $data | The related data to export. |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::export_user_preference | ( | string | $component, |
string | $key, | ||
string | $value, | ||
string | $description ) |
Export the specified user preference.
string | $component | The name of the component. |
string | $key | The name of th key to be exported. |
string | $value | The value of the preference |
string | $description | A description of the value |
core_privacy\local\request\content_writer |
Implements core_privacy\local\request\content_writer.
|
protected |
Fetch the data region of the specified root.
stdClass | $base | The base to use - e.g. $this->data |
array | $subcontext | The subcontext to fetch |
stdClass|array |
|
protected |
Fetch the entire root record at the specified location type, creating it if required.
stdClass | $base | The base to use - e.g. $this->data |
array | $subcontext | The subcontext to fetch |
int | $temporarycontextid | A temporary context ID to use for the fetch. |
stdClass|array |
core_privacy\tests\request\content_writer::finalise_content | ( | ) |
Perform any required finalisation steps and return the location of the finalised export.
string |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::get_all_metadata | ( | array | $subcontext = [] | ) |
Get all metadata within the subcontext.
array | $subcontext | The location within the current context that this data belongs. |
stdClass|array | The metadata as a series of keys to value + description objects. |
core_privacy\tests\request\content_writer::get_current_context | ( | ) |
Return the current context.
context |
core_privacy\tests\request\content_writer::get_custom_file | ( | array | $subcontext = [], |
$filename = null ) |
Get the specified custom file within the subcontext.
array | $subcontext | The location within the current context that this data belongs. |
string | $filename | The name of the file to be fetched within the context + subcontext. |
string | The content of the file. |
core_privacy\tests\request\content_writer::get_data | ( | array | $subcontext = [] | ) |
Get all data within the subcontext.
array | $subcontext | The location within the current context that this data belongs. |
stdClass|array | The metadata as a series of keys to value + description objects. |
core_privacy\tests\request\content_writer::get_files | ( | array | $subcontext = [] | ) |
Get all files in the specfied subcontext.
array | $subcontext | The location within the current context that this data belongs. |
stored_file[] | The list of stored_files in this context + subcontext. |
core_privacy\tests\request\content_writer::get_metadata | ( | array | $subcontext, |
$key, | |||
$valueonly = true ) |
Get the specified metadata within the subcontext.
array | $subcontext | The location within the current context that this data belongs. |
string | $key | The metadata to be fetched within the context + subcontext. |
boolean | $valueonly | Whether to fetch only the value, rather than the value + description. |
stdClass|array|null | The metadata as a series of keys to value + description objects. |
core_privacy\tests\request\content_writer::get_related_data | ( | array | $subcontext = [], |
$filename = null ) |
Get all data within the subcontext.
array | $subcontext | The location within the current context that this data belongs. |
string | $filename | The name of the intended filename. |
stdClass|array | The metadata as a series of keys to value + description objects. |
core_privacy\tests\request\content_writer::get_user_context_preferences | ( | string | $component | ) |
Get all user preferences for the specified component.
string | $component | The name of the component. |
stdClass |
core_privacy\tests\request\content_writer::get_user_preferences | ( | string | $component | ) |
Get all user preferences for the specified component.
string | $component | The name of the component. |
stdClass |
core_privacy\tests\request\content_writer::has_any_data | ( | $subcontext = [] | ) |
Whether any data has been exported at all within the current context.
array | $subcontext | The location within the current context that this data belongs - in this method it can be partial subcontext path (or none at all to check presence of any data anywhere). User preferences never have subcontext, if $subcontext is specified, user preferences are not checked. |
bool |
core_privacy\tests\request\content_writer::has_any_data_in_any_context | ( | ) |
Whether any data has been exported for any context.
bool |
core_privacy\tests\request\content_writer::rewrite_pluginfile_urls | ( | array | $subcontext, |
$component, | |||
$filearea, | |||
$itemid, | |||
$text ) |
Prepare a text area by processing pluginfile URLs within it.
Note that this method does not implement the pluginfile URL rewriting. Such a job tightly depends on how the actual writer exports files so it can be reliably tested only in real writers such as core_privacy::local::request::moodle_content_writer.
However we have to remove @PLUGINFILE@ since otherwise format_text() shows debugging messages
array | $subcontext | The location within the current context that this data belongs. |
string | $component | The name of the component that the files belong to. |
string | $filearea | The filearea within that component. |
string | $itemid | Which item those files belong to. |
string | $text | The text to be processed |
string | The processed string |
Implements core_privacy\local\request\content_writer.
core_privacy\tests\request\content_writer::set_context | ( | \context | $context | ) |
Set the context for the current item being processed.
context | $context | The context to use |
Implements core_privacy\local\request\content_writer.