Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

File Size: 268 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: block  - X-Ref

Block context class

__construct(stdClass $record)   X-Ref
Please use \core\context\block::instance($blockinstanceid) if you need the instance of context.
Alternatively if you know only the context id use \core\context::instance_by_id($contextid)

param: stdClass $record

get_short_name()   X-Ref
Returns short context name.

return: string

get_level_name()   X-Ref
Returns human readable context level name.

return: string the human readable context level name.

get_context_name($withprefix = true, $short = false, $escape = true)   X-Ref
Returns human readable context identifier.

param: boolean $withprefix whether to prefix the name of the context with Block
param: boolean $short does not apply to block context
param: boolean $escape does not apply to block context
return: string the human readable context name.

get_url()   X-Ref
Returns the most relevant URL for this context.

return: moodle_url

get_possible_parent_levels()   X-Ref
Returns list of all possible parent context levels.

return: int[]

get_capabilities(string $sort = self::DEFAULT_CAPABILITY_SORT)   X-Ref
Returns array of relevant context capability records.

param: string $sort
return: array

get_course_context($strict = true)   X-Ref
Is this context part of any course? If yes return course context.

param: bool $strict true means throw exception if not found, false means return false if not found
return: course context of the enclosing course, null if not found or exception

instance($blockinstanceid, $strictness = MUST_EXIST)   X-Ref
Returns block context instance.

param: int $blockinstanceid id from {block_instances} table.
param: int $strictness
return: block|false context instance

get_child_contexts()   X-Ref
Block do not have child contexts...

return: array

create_level_instances()   X-Ref
Create missing context instances at block context level


get_cleanup_sql()   X-Ref
Returns sql necessary for purging of stale context instances.

return: string cleanup SQL

build_paths($force)   X-Ref
Rebuild context paths and depths at block context level.

param: bool $force