Skip to content

Commit

Permalink
MDL-78294 core_tag: New 'viewurl' property in tag_item_exporter
Browse files Browse the repository at this point in the history
New additional property 'viewurl' has been added to the pre-defined
structure in tag_item_exporter. This property represents the URL to
view a given tag.
  • Loading branch information
Mihail Geshoski committed Nov 24, 2023
1 parent 6374475 commit 80d8263
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tag/classes/external/tag_item_exporter.php
Expand Up @@ -27,6 +27,7 @@
defined('MOODLE_INTERNAL') || die();

use core\external\exporter;
use renderer_base;

/**
* Contains related class for displaying information of a tag item.
Expand Down Expand Up @@ -89,4 +90,33 @@ protected static function define_properties() {
],
];
}

/**
* Return the list of additional properties used only for display.
*
* @return array
*/
protected static function define_other_properties() {
return [
'viewurl' => [
'type' => PARAM_URL,
'description' => 'The url to view the tag.',
'optional' => true,
'default' => null,
'null' => NULL_ALLOWED,
],
];
}

/**
* Get the additional values to inject while exporting.
*
* @param renderer_base $output The renderer.
* @return array Keys are the property names, values are their values.
*/
protected function get_other_values(renderer_base $output) {
return [
'viewurl' => \core_tag_tag::make_url($this->data->tagcollid, $this->data->rawname)->out(false),
];
}
}
5 changes: 5 additions & 0 deletions tag/upgrade.txt
@@ -1,6 +1,11 @@
This files describes API changes in tagging, information provided
here is intended especially for developers.

=== 4.4 ===

* New additional property 'viewurl' has been added to the pre-defined structure in tag_item_exporter. This property
represents the URL to view a given tag.

=== 3.6 ===

* The following functions have been finally deprecated and can not be used anymore:
Expand Down

0 comments on commit 80d8263

Please sign in to comment.