mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 11:26:41 +02:00
MDL-65313 core_favourite: add component-scoped favourite service class
Added a new type of service which can be used to interact with the all favourites for a given component, not just those owned by a a specific user. As such, objects of this type are scoped to a component.
This commit is contained in:
parent
a411b499b9
commit
f962859b56
4 changed files with 358 additions and 0 deletions
|
@ -45,5 +45,15 @@ class service_factory {
|
|||
public static function get_service_for_user_context(\context_user $context) : local\service\user_favourite_service {
|
||||
return new local\service\user_favourite_service($context, new local\repository\favourite_repository());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a basic service object providing operations for favourites belonging to a given component.
|
||||
*
|
||||
* @param string $component frankenstyle component name.
|
||||
* @return local\service\component_favourite_service the service object.
|
||||
*/
|
||||
public static function get_service_for_component(string $component) : local\service\component_favourite_service {
|
||||
return new local\service\component_favourite_service($component, new local\repository\favourite_repository());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue