Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Contains the favourite_repository interface.

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

Defines 1 class

favourite_repository_interface:: (13 methods):
  add()
  add_all()
  find()
  find_all()
  find_by()
  exists()
  exists_by()
  count()
  count_by()
  update()
  delete()
  delete_by()
  find_favourite()


Interface: favourite_repository_interface  - X-Ref

The favourite_repository interface, defining the basic CRUD operations for favourite type items within core_favourites.

add(favourite $item)   X-Ref
Add one item to this repository.

param: favourite $item the item to add.
return: favourite the item which was added.

add_all(array $items)   X-Ref
Add all the items in the list to this repository.

param: array $items the list of items to add.
return: array the list of items added to this repository.

find(int $id)   X-Ref
Find an item in this repository based on its id.

param: int $id the id of the item.
return: favourite the item.

find_all(int $limitfrom = 0, int $limitnum = 0)   X-Ref
Find all items in this repository.

param: int $limitfrom optional pagination control for returning a subset of records, starting at this point.
param: int $limitnum optional pagination control for returning a subset comprising this many records.
return: array list of all items in this repository.

find_by(array $criteria, int $limitfrom = 0, int $limitnum = 0)   X-Ref
Find all items with attributes matching certain values.

param: array $criteria the array of attribute/value pairs.
param: int $limitfrom optional pagination control for returning a subset of records, starting at this point.
param: int $limitnum optional pagination control for returning a subset comprising this many records.
return: array the list of items matching the criteria.

exists(int $id)   X-Ref
Check whether an item exists in this repository, based on its id.

param: int $id the id to search for.
return: bool true if the item could be found, false otherwise.

exists_by(array $criteria)   X-Ref
Check whether an item exists in this repository, based on the specified criteria.

param: array $criteria the list of key/value criteria pairs.
return: bool true if the favourite exists, false otherwise.

count()   X-Ref
Return the total number of items in this repository.

return: int the total number of items.

count_by(array $criteria)   X-Ref
Return the number of favourites matching the specified criteria.

param: array $criteria the list of key/value criteria pairs.
return: int the number of favourites matching the criteria.

update(favourite $item)   X-Ref
Update an item within this repository.

param: favourite $item the item to update.
return: favourite the updated item.

delete(int $id)   X-Ref
Delete an item by id.

param: int $id the id of the item to delete.
return: void

delete_by(array $criteria)   X-Ref
Delete all favourites matching the specified criteria.

param: array $criteria the list of key/value criteria pairs.
return: void.

find_favourite(int $userid, string $component, string $itemtype, int $itemid, int $contextid)   X-Ref
Find a single favourite, based on it's unique identifiers.

param: int $userid the id of the user to which the favourite belongs.
param: string $component the frankenstyle component name.
param: string $itemtype the type of the favourited item.
param: int $itemid the id of the item which was favourited (not the favourite's id).
param: int $contextid the contextid of the item which was favourited.
return: favourite the favourite.