Skip to content

Commit

Permalink
MDL-29996 remove legacy_filter support
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Dec 30, 2012
1 parent d8e74f5 commit fba0abd
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions lib/filterlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ protected function make_filter_object($filtername, $context, $localconfig) {
return new $filterclassname($context, $localconfig);
}

// TODO: deprecated since 2.2, will be out in 2.3, see MDL-29996
$legacyfunctionname = basename($filtername) . '_filter';
if (function_exists($legacyfunctionname)) {
return new legacy_filter($legacyfunctionname, $context, $localconfig);
}

return null;
}

Expand Down Expand Up @@ -408,50 +402,6 @@ public function setup($page, $context) {
public abstract function filter($text, array $options = array());
}

/**
* moodle_text_filter implementation that encapsulates an old-style filter that
* only defines a function, not a class.
*
* @deprecated since 2.2, see MDL-29995
* @todo will be out in 2.3, see MDL-29996
* @package core
* @subpackage filter
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class legacy_filter extends moodle_text_filter {
/** @var string */
protected $filterfunction;
protected $courseid;

/**
* Set any context-specific configuration for this filter.
*
* @param string $filterfunction
* @param object $context The current context.
* @param array $config Any context-specific configuration for this filter.
*/
public function __construct($filterfunction, $context, array $localconfig) {
parent::__construct($context, $localconfig);
$this->filterfunction = $filterfunction;
$this->courseid = get_courseid_from_context($this->context);
}

/**
* @param string $text
* @param array $options options - not supported for legacy filters
* @return mixed
*/
public function filter($text, array $options = array()) {
if ($this->courseid) {
// old filters are called only when inside courses
return call_user_func($this->filterfunction, $this->courseid, $text);
} else {
return $text;
}
}
}

/**
* This is just a little object to define a phrase and some instructions
* for how to process it. Filters can create an array of these to pass
Expand Down

0 comments on commit fba0abd

Please sign in to comment.