Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_favourites\local\service\component_favourite_service Class Reference

Class service, providing an single API for interacting with the favourites subsystem, for all favourites of a specific component. More...

Public Member Functions

 __construct (string $component, favourite_repository_interface $repository)
 The component_favourite_service constructor.
 
 delete_favourites_by_type_and_item (string $itemtype, int $itemid, context $context=null)
 Delete a collection of favourites by type and item, and optionally for a given context.
 

Protected Attributes

int $component
 $component the frankenstyle component name to which this favourites service is scoped.
 
favourite_repository_interface $repo
 $repo the favourite repository object.
 

Detailed Description

Class service, providing an single API for interacting with the favourites subsystem, for all favourites of a specific component.

This class provides operations which can be applied to favourites within a component, based on type and context identifiers.

All object persistence is delegated to the favourite_repository_interface object.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_favourites\local\service\component_favourite_service::__construct ( string $component,
favourite_repository_interface $repository )

The component_favourite_service constructor.

Parameters
string$componentThe frankenstyle name of the component to which this service operations are scoped.
core_favourites\local\repository\favourite_repository_interface$repositorya favourites repository.
Exceptions
moodle_exceptionif the component name is invalid.

Member Function Documentation

◆ delete_favourites_by_type_and_item()

core_favourites\local\service\component_favourite_service::delete_favourites_by_type_and_item ( string $itemtype,
int $itemid,
context $context = null )

Delete a collection of favourites by type and item, and optionally for a given context.

E.g. delete all favourites of type 'message_conversations' for the conversation '11' and in the CONTEXT_COURSE context.

Parameters
string$itemtypethe type of the favourited items.
int$itemidthe id of the item to which the favourites relate
context$contextthe context of the items which were favourited.

The documentation for this class was generated from the following file: