return context_system::instance(0, IGNORE_MISSING, $cache);
}
--/**
- * Get a context instance as an object, from a given context id.
- * Get the context instance as an object. This function will create the
- * context instance if it does not exist yet.
-- *
- * @deprecated since 2.2, use context::instance_by_id($id) instead
- * @param int $id context id
- * @deprecated since 2.2, use context_course::instance() or other relevant class instead
- * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE.
- * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id,
- * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0
-- * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
- * MUST_EXIST means throw exception if no record or multiple records found
- * @return context|bool the context object or false if not found.
- * MUST_EXIST means throw exception if no record or multiple records found
- * @return context The context object.
-- */
- function get_context_instance_by_id($id, $strictness = IGNORE_MISSING) {
- return context::instance_by_id($id, $strictness);
-function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) {
- $instances = (array)$instance;
- $contexts = array();
-
- $classname = context_helper::get_class_for_level($contextlevel);
-
- // we do not load multiple contexts any more, PAGE should be responsible for any preloading
- foreach ($instances as $inst) {
- $contexts[$inst] = $classname::instance($inst, $strictness);
- }
-
- if (is_array($instance)) {
- return $contexts;
- } else {
- return $contexts[$instance];
- }
--}
--
/**
* Recursive function which, given a context, find all parent context ids,
* and return the array in reverse order, i.e. parent first, then grand
return true;
}
+/**
+ * Get the context instance as an object. This function will create the
+ * context instance if it does not exist yet.
+ *
+ * @deprecated since 2.2, use context_course::instance() or other relevant class instead
+ * @todo This will be deleted in Moodle 2.8, refer MDL-34472
+ * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE.
+ * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id,
+ * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0
+ * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
+ * MUST_EXIST means throw exception if no record or multiple records found
+ * @return context The context object.
+ */
+function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) {
+
+ debugging('get_context_instance() is deprecated, please use respective context_xxxx::instance().', DEBUG_DEVELOPER);
+
+ $instances = (array)$instance;
+ $contexts = array();
+
+ $classname = context_helper::get_class_for_level($contextlevel);
+
+ // we do not load multiple contexts any more, PAGE should be responsible for any preloading
+ foreach ($instances as $inst) {
+ $contexts[$inst] = $classname::instance($inst, $strictness);
+ }
+
+ if (is_array($instance)) {
+ return $contexts;
+ } else {
+ return $contexts[$instance];
+ }
+}
++
+ /**
+ * Get a context instance as an object, from a given context id.
+ *
+ * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
+ * @todo MDL-34550 This will be deleted in Moodle 2.8
+ * @see context::instance_by_id($id)
+ * @param int $id context id
+ * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
+ * MUST_EXIST means throw exception if no record or multiple records found
+ * @return context|bool the context object or false if not found.
+ */
+ function get_context_instance_by_id($id, $strictness = IGNORE_MISSING) {
+ debugging('Function get_context_instance_by_id() is deprecated, please use context::instance_by_id($id) instead', DEBUG_DEVELOPER);
+ return context::instance_by_id($id, $strictness);
+ }
=== 2.6 ===
* Use new core_component::* plugin listing and component normalisation methods.
+* Use core_text::* instead of textlib:: and also core_collator::* instead of collatorlib::*.
+* get_context_instance() now throws deprecated warning.
+ * get_context_instance_by_id() is deprecated, please use context::instance_by_id($id)
=== 2.5.1 ===