MDL-70438 contentbank: Add method get_uses to content

This commit is contained in:
Sara Arjona 2020-12-09 13:34:41 +01:00
parent c381757f2a
commit 890d0690d4
3 changed files with 79 additions and 0 deletions

View file

@ -310,6 +310,24 @@ abstract class content {
return null;
}
/**
* Returns the places where the file associated to this content is used or an empty array if the content has no file.
*
* @return array of stored_file where current file content is used or empty array if it hasn't any file.
* @since 3.11
*/
public function get_uses(): ?array {
$references = [];
$file = $this->get_file();
if ($file != null) {
$fs = get_file_storage();
$references = $fs->get_references_by_storedfile($file);
}
return $references;
}
/**
* Returns the file url related to this content.
*