mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-70438 contentbank: Add method get_uses to content
This commit is contained in:
parent
c381757f2a
commit
890d0690d4
3 changed files with 79 additions and 0 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue