Generic exporter to take a stdClass and prepare it for return by webservice, or as the context for a template.
More...
Generic exporter to take a stdClass and prepare it for return by webservice, or as the context for a template.
templatable classes implementing export_for_template, should always use a standard exporter if it exists. External functions should always use a standard exporter if it exists.
- Copyright
- 2015 Damyon Wiese
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
static core\external\exporter::define_other_properties |
( |
| ) |
|
|
staticprotected |
Return the list of additional properties used only for display.
Additional properties are only ever used for the read structure, and during export of the persistent data.
The format of the array returned by this method has to match the structure defined in (). The display properties can however do some more fancy things. They can define 'multiple' => true to wrap values in an external_multiple_structure automatically - or they can define the type as a nested array of more properties in order to generate a nested external_single_structure.
You can specify an array of values by including a 'multiple' => true array value. This will result in a nested external_multiple_structure. E.g.
'arrayofbools' => array(
'type' => PARAM_BOOL,
'multiple' => true
),
You can return a nested array in the type field, which will result in a nested external_single_structure. E.g. 'competency' => array( 'type' => competency_exporter::read_properties_definition() ),
Other properties can be specifically marked as optional, in which case they do not need to be included in the export in self::get_other_values(). This is useful when exporting a substructure which cannot be set as null due to webservices protocol constraints. E.g. 'competency' => array( 'type' => competency_exporter::read_properties_definition(), 'optional' => true ),
- Return values
-
Reimplemented in core_competency\external\user_summary_exporter, core_tag\external\tag_area_exporter, core_question\external\question_summary_exporter, mod_workshop\external\workshop_summary_exporter, mod_workshop\external\submission_exporter, mod_workshop\external\assessment_exporter, mod_lesson\external\lesson_summary_exporter, mod_forum\local\exporters\posts, mod_forum\local\exporters\post, mod_forum\local\exporters\group, mod_forum\local\exporters\forum, mod_forum\local\exporters\discussion_summary, mod_forum\local\exporters\discussion_summaries, mod_forum\local\exporters\discussion, mod_forum\local\exporters\author, mod_feedback\external\feedback_summary_exporter, mod_feedback\external\feedback_item_exporter, mod_data\external\record_exporter, mod_data\external\database_summary_exporter, mod_data\external\content_exporter, core\external\paged_content_exporter, core\external\coursecat_summary_exporter, core_files\external\stored_file_exporter, core_course\external\course_summary_exporter, core_course\external\course_module_summary_exporter, core_competency\external\user_evidence_exporter, core_competency\external\user_competency_plan_exporter, core_competency\external\user_competency_exporter, core_competency\external\user_competency_course_exporter, core_competency\external\template_exporter, core_competency\external\plan_exporter, core_competency\external\evidence_exporter, core_competency\external\competency_framework_exporter, core_comment\external\comment_area_exporter, core_cohort\external\cohort_summary_exporter, core_calendar\external\week_exporter, core_calendar\external\week_day_exporter, core_calendar\external\month_exporter, core_calendar\external\footer_options_exporter, core_calendar\external\events_same_course_exporter, core_calendar\external\events_grouped_by_course_exporter, core_calendar\external\events_exporter, core_calendar\external\event_exporter_base, core_calendar\external\event_exporter, core_calendar\external\event_action_exporter, core_calendar\external\day_exporter, core_calendar\external\calendar_upcoming_exporter, core_calendar\external\calendar_event_exporter, core_calendar\external\calendar_day_exporter, core_blog\external\post_exporter, core_competency\external\recentlyaccesseditems_item_exporter, core_badges\external\user_badge_exporter, core_badges\external\badgeclass_exporter, core_badges\external\assertion_exporter, tool_policy\policy_version_exporter, tool_policy\policy_exporter, tool_lp\external\user_evidence_summary_exporter, tool_lp\external\user_evidence_competency_summary_exporter, tool_lp\external\user_competency_summary_in_plan_exporter, tool_lp\external\user_competency_summary_in_course_exporter, tool_lp\external\user_competency_summary_exporter, tool_lp\external\template_statistics_exporter, tool_lp\external\course_competency_statistics_exporter, tool_lp\external\competency_summary_exporter, tool_lp\external\competency_path_exporter, tool_dataprivacy\external\purpose_exporter, and tool_dataprivacy\external\data_request_exporter.
static core\external\exporter::define_properties |
( |
| ) |
|
|
staticprotected |
Return the list of properties.
The format of the array returned by this method has to match the structure defined in (). Howewer you can add a new attribute "description" to describe the parameter for documenting the API.
Note that the type PARAM_TEXT should ONLY be used for strings which need to go through filters (multilang, etc...) and do not have a FORMAT_* associated to them. Typically strings passed through to format_string().
Other filtered strings which use a FORMAT_* constant (hear used with format_text) must be defined as PARAM_RAW.
- Return values
-
Reimplemented in core_competency\external\user_summary_exporter, core_tag\external\tag_item_exporter, core_tag\external\tag_collection_exporter, core_tag\external\tag_area_exporter, core_question\external\question_summary_exporter, core_question\external\question_icon_exporter, mod_workshop\external\workshop_summary_exporter, mod_workshop\external\submission_exporter, mod_workshop\external\assessment_exporter, mod_lesson\external\lesson_summary_exporter, mod_feedback\external\feedback_valuetmp_exporter, mod_feedback\external\feedback_value_exporter, mod_feedback\external\feedback_summary_exporter, mod_feedback\external\feedback_item_exporter, mod_feedback\external\feedback_completedtmp_exporter, mod_feedback\external\feedback_completed_exporter, mod_data\external\record_exporter, mod_data\external\field_exporter, mod_data\external\database_summary_exporter, mod_data\external\content_exporter, mod_chat\external\chat_message_exporter, core\external\persistent_exporter, core\external\coursecat_summary_exporter, core_files\external\stored_file_exporter, core_course\external\course_summary_exporter, core_comment\external\comment_area_exporter, core_cohort\external\cohort_summary_exporter, core_calendar\external\week_day_exporter, core_calendar\external\month_exporter, core_calendar\external\event_subscription_exporter, core_calendar\external\event_icon_exporter, core_calendar\external\event_exporter_base, core_calendar\external\event_action_exporter, core_calendar\external\day_name_exporter, core_calendar\external\day_exporter, core_calendar\external\date_exporter, core_blog\external\post_exporter, core_competency\external\recentlyaccesseditems_item_exporter, core_badges\external\verification_exporter, core_badges\external\user_badge_exporter, core_badges\external\related_info_exporter, core_badges\external\recipient_exporter, core_badges\external\issuer_exporter, core_badges\external\endorsement_exporter, core_badges\external\collection_exporter, core_badges\external\badgeclass_exporter, core_badges\external\backpack_exporter, core_badges\external\assertion_exporter, core_badges\external\alignment_exporter, tool_policy\policy_version_exporter, tool_policy\policy_exporter, tool_lp\external\template_statistics_exporter, tool_lp\external\path_node_exporter, tool_lp\external\course_competency_statistics_exporter, and tool_dataprivacy\external\name_description_exporter.
core\external\exporter::get_format_parameters |
( |
|
$property | ) |
|
|
finalprotected |
Get the format parameters.
This method returns the parameters to use with the functions external_format_text(), and external_format_string(). To override the default parameters, you can define a protected method called 'get_format_parameters_for_<propertyName>'. For example, 'get_format_parameters_for_description', if your property is 'description'.
Your method must return an array containing any of the following keys:
- Parameters
-
string | $property | The property to get the parameters for. |
- Return values
-
core\external\exporter::get_other_values |
( |
renderer_base |
$output | ) |
|
|
protected |
Get the additional values to inject while exporting.
These are additional generated values that are not passed in through $data to the exporter. For a persistent exporter - these are generated values that do not exist in the persistent class. For your convenience the format_text or format_string functions do not need to be applied to PARAM_TEXT fields, it will be done automatically during export.
These values are only used when returning data via self::export(), they are not used when generating any of the different external structures.
Note: These must be defined in self::define_other_properties().
- Parameters
-
- Return values
-
array | Keys are the property names, values are their values. |
Reimplemented in core_competency\external\user_summary_exporter, core_tag\external\tag_area_exporter, mod_workshop\external\workshop_summary_exporter, mod_workshop\external\submission_exporter, mod_workshop\external\assessment_exporter, mod_lesson\external\lesson_summary_exporter, mod_forum\local\exporters\posts, mod_forum\local\exporters\post, mod_forum\local\exporters\group, mod_forum\local\exporters\forum, mod_forum\local\exporters\discussion_summary, mod_forum\local\exporters\discussion_summaries, mod_forum\local\exporters\discussion, mod_forum\local\exporters\author, mod_feedback\external\feedback_summary_exporter, mod_feedback\external\feedback_item_exporter, mod_data\external\record_exporter, mod_data\external\database_summary_exporter, mod_data\external\content_exporter, core\external\paged_content_exporter, core\external\coursecat_summary_exporter, core_files\external\stored_file_exporter, core_course\external\course_summary_exporter, core_course\external\course_module_summary_exporter, core_competency\external\user_evidence_exporter, core_competency\external\user_competency_plan_exporter, core_competency\external\user_competency_exporter, core_competency\external\user_competency_course_exporter, core_competency\external\template_exporter, core_competency\external\plan_exporter, core_competency\external\evidence_exporter, core_competency\external\competency_framework_exporter, core_comment\external\comment_area_exporter, core_cohort\external\cohort_summary_exporter, core_calendar\external\week_exporter, core_calendar\external\week_day_exporter, core_calendar\external\month_exporter, core_calendar\external\footer_options_exporter, core_calendar\external\events_same_course_exporter, core_calendar\external\events_grouped_by_course_exporter, core_calendar\external\events_exporter, core_calendar\external\event_exporter_base, core_calendar\external\event_exporter, core_calendar\external\event_action_exporter, core_calendar\external\day_exporter, core_calendar\external\calendar_upcoming_exporter, core_calendar\external\calendar_event_exporter, core_calendar\external\calendar_day_exporter, core_blog\external\post_exporter, core_competency\external\recentlyaccesseditems_item_exporter, core_badges\external\user_badge_exporter, core_badges\external\badgeclass_exporter, core_badges\external\assertion_exporter, tool_policy\policy_version_exporter, tool_policy\policy_exporter, tool_lp\external\user_evidence_summary_exporter, tool_lp\external\user_evidence_competency_summary_exporter, tool_lp\external\user_competency_summary_in_plan_exporter, tool_lp\external\user_competency_summary_in_course_exporter, tool_lp\external\user_competency_summary_exporter, tool_lp\external\template_statistics_exporter, tool_lp\external\course_competency_statistics_exporter, tool_lp\external\competency_summary_exporter, tool_lp\external\competency_path_exporter, tool_dataprivacy\external\purpose_exporter, and tool_dataprivacy\external\data_request_exporter.