MDL-68636 core_contentbank: Changing get_icon function

This commit is contained in:
Amaia Anabitarte 2020-05-06 10:11:35 +02:00
parent f9830e456a
commit 6fc3477cc5
7 changed files with 81 additions and 16 deletions

View file

@ -106,7 +106,10 @@ class core_contenttype_contenttype_testcase extends \advanced_testcase {
$systemcontext = \context_system::instance();
$testable = new contenttype($systemcontext);
$icon = $testable->get_icon('new content');
$record = new stdClass();
$record->name = 'New content';
$content = $testable->create_content($record);
$icon = $testable->get_icon($content);
$this->assertContains('archive', $icon);
}

View file

@ -43,7 +43,7 @@ class contenttype extends \core_contentbank\contenttype {
* @param content $content The content to delete.
* @return string URL where to visualize the given content.
*/
public function get_view_url(content $content): string {
public function get_view_url(\core_contentbank\content $content): string {
$fileurl = $this->get_file_url($content->get_id());
$url = $fileurl."?forcedownload=1";
@ -53,13 +53,13 @@ class contenttype extends \core_contentbank\contenttype {
/**
* Returns the HTML code to render the icon for content bank contents.
*
* @param string $contentname The contentname to add as alt value to the icon.
* @param content $content The content to delete.
* @return string HTML code to render the icon
*/
public function get_icon(string $contentname): string {
public function get_icon(\core_contentbank\content $content): string {
global $OUTPUT;
return $OUTPUT->pix_icon('f/archive-64', $contentname, 'moodle', ['class' => 'iconsize-big']);
return $OUTPUT->image_url('f/archive-64', 'moodle')->out(false);
}
/**