Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

Base implementation of a contextlist.

Copyright: 2018 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 187 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

contextlist_base:: (11 methods):
  set_contextids()
  get_contextids()
  get_contexts()
  set_component()
  get_component()
  current()
  key()
  next()
  valid()
  rewind()
  count()


Class: contextlist_base  - X-Ref

Base implementation of a contextlist used to store a set of contexts.

set_contextids(array $contextids)   X-Ref
Set the contextids.

param: array   $contextids The list of contexts.

get_contextids()   X-Ref
Get the list of context IDs that relate to this request.

return: int[]

get_contexts()   X-Ref
Get the complete list of context objects that relate to this
request.

return: \context[]

set_component($component)   X-Ref
Sets the component for this contextlist.

param: string $component the frankenstyle component name.

get_component()   X-Ref
Get the name of the component to which this contextlist belongs.

return: string the component name associated with this contextlist.

current()   X-Ref
Return the current context.

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.

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