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:
Jake Dallimore 2019-04-10 09:36:45 +08:00
parent a411b499b9
commit f962859b56
4 changed files with 358 additions and 0 deletions

View file

@ -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());
}
}