Differences Between: [Versions 310 and 400] [Versions 39 and 400]
Contains the content_item_service class.
Copyright: | 2020 Jake Dallimore <jrhdallimore@gmail.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 386 lines (17 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
content_item_service:: (11 methods):
__construct()
get_favourite_content_items_for_user()
get_recommendations()
get_content_favourites()
get_all_content_items()
get_content_items_by_name_pattern()
export_content_items()
get_content_items_for_user_in_course()
add_to_user_favourites()
remove_from_user_favourites()
toggle_recommendation()
Class: content_item_service - X-Ref
The content_item_service class, providing the api for interacting with content items.__construct(content_item_readonly_repository_interface $repository) X-Ref |
The content_item_service constructor. param: content_item_readonly_repository_interface $repository a content item repository. |
get_favourite_content_items_for_user(\stdClass $user) X-Ref |
Returns an array of objects representing favourited content items. Each object contains the following properties: itemtype: a string containing the 'itemtype' key used by the favourites subsystem. ids[]: an array of ids, representing the content items within a component. Since two components can return (via their hook implementation) the same id, the itemtype is used for uniqueness. return: array param: \stdClass $user |
get_recommendations() X-Ref |
Returns an array of objects representing recommended content items. Each object contains the following properties: itemtype: a string containing the 'itemtype' key used by the favourites subsystem. ids[]: an array of ids, representing the content items within a component. Since two components can return (via their hook implementation) the same id, the itemtype is used for uniqueness. return: array |
get_content_favourites(string $prefix, \context_user $usercontext) X-Ref |
Gets content favourites from the favourites system depending on the area. return: array An array of favourite objects. param: string $prefix Prefix for the item type. param: \context_user $usercontext User context for the favourite |
get_all_content_items(\stdClass $user) X-Ref |
Get all content items which may be added to courses, irrespective of course caps, for site admin views, etc. return: array the array of exported content items. param: \stdClass $user the user object. |
get_content_items_by_name_pattern(\stdClass $user, string $pattern) X-Ref |
Get content items which name matches a certain pattern and may be added to courses, irrespective of course caps, for site admin views, etc. return: array The array of exported content items. param: \stdClass $user The user object. param: string $pattern The search pattern. |
export_content_items(\stdClass $user, $contentitems) X-Ref |
Export content items. return: array The array of exported content items. param: \stdClass $user The user object. param: array $contentitems The content items array. |
get_content_items_for_user_in_course(\stdClass $user, \stdClass $course, array $linkparams = []) X-Ref |
Return a representation of the available content items, for a user in a course. return: \stdClass[] the content items, scoped to a course. param: \stdClass $user the user to check access for. param: \stdClass $course the course to scope the content items to. param: array $linkparams the desired section to return to. |
add_to_user_favourites(\stdClass $user, string $componentname, int $contentitemid) X-Ref |
Add a content item to a user's favourites. return: \stdClass the exported content item. param: \stdClass $user the user whose favourite this is. param: string $componentname the name of the component from which the content item originates. param: int $contentitemid the id of the content item. |
remove_from_user_favourites(\stdClass $user, string $componentname, int $contentitemid) X-Ref |
Remove the content item from a user's favourites. return: \stdClass the exported content item. param: \stdClass $user the user whose favourite this is. param: string $componentname the name of the component from which the content item originates. param: int $contentitemid the id of the content item. |
toggle_recommendation(string $itemtype, int $itemid) X-Ref |
Toggle an activity to being recommended or not. return: bool True on creating a favourite, false on deleting it. param: string $itemtype The component such as mod_assign, or assignsubmission_file param: int $itemid The id related to this component item. |