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.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

This file defines the contextlist_collection class object. The contextlist_collection is used to organize a collection of contextlists.

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

Defines 1 class

contextlist_collection:: (12 methods):
  __construct()
  get_userid()
  add_contextlist()
  get_contextlists()
  get_contextlist_for_component()
  current()
  key()
  next()
  valid()
  rewind()
  get_key_from_position()
  count()


Class: contextlist_collection  - X-Ref

A collection of contextlist items.

__construct($userid)   X-Ref
Constructor to create a new contextlist_collection.

param: int     $userid The userid to which this collection belongs.

get_userid()   X-Ref
Return the ID of the user whose collection this is.

return: int

add_contextlist(contextlist_base $contextlist)   X-Ref
Add a contextlist to this collection.

param: contextlist_base $contextlist the contextlist to export.
return: $this

get_contextlists()   X-Ref
Get the contextlists in this collection.

return: array   the associative array of contextlists in this collection, indexed by component name.

get_contextlist_for_component(string $component)   X-Ref
Get the contextlist for the specified component.

param: string      $component the frankenstyle name of the component to fetch for.
return: contextlist_base|null

current()   X-Ref
Return the current contexlist.

return: \context

key()   X-Ref
Return the key of the current element.

return: mixed

next()   X-Ref
Move to the next context in the list.


valid()   X-Ref
Check if the current position is valid.

return: bool

rewind()   X-Ref
Rewind to the first found context.

The list of contexts is uniqued during the rewind.
The rewind is called at the start of most iterations.

get_key_from_position()   X-Ref
Get the key for the current iterator position.

return: string

count()   X-Ref
Return the number of contexts.