Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Contains the component_favourite_service class, part of the service layer for the favourites subsystem.

Copyright: 2019 Jake Dallimore <jrhdallimore@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 77 lines (3 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

component_favourite_service:: (2 methods):
  __construct()
  delete_favourites_by_type_and_item()


Class: component_favourite_service  - X-Ref

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.

__construct(string $component, favourite_repository_interface $repository)   X-Ref
The component_favourite_service constructor.

param: string $component The frankenstyle name of the component to which this service operations are scoped.
param: \core_favourites\local\repository\favourite_repository_interface $repository a favourites repository.

delete_favourites_by_type_and_item(string $itemtype, int $itemid, \context $context = null)   X-Ref
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.

param: string $itemtype the type of the favourited items.
param: int $itemid the id of the item to which the favourites relate
param: \context $context the context of the items which were favourited.