From 3405956553a6f12bbbe80e27a3f6cfc8c8a16304 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 27 Dec 2009 12:58:29 +0000 Subject: [PATCH] MDL-21197 output components do not use globals any more in prepare() methods --- lib/outputcomponents.php | 135 +++++++++++++++++++++++---------------- lib/outputrenderers.php | 46 ++++++------- 2 files changed, 102 insertions(+), 79 deletions(-) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 39c1a30365..2b246d92da 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -117,10 +117,15 @@ class moodle_html_component { /** * Perform any cleanup or final processing that should be done before an - * instance of this class is output. + * instance of this class is output. This method is supposed to be called + * only from renderers. + * + * @param renderer_base $output output renderer + * @param moodle_page $page + * @param string $target rendering target * @return void */ - public function prepare() { + public function prepare(renderer_base $output, moodle_page $page, $target) { $this->classes = array_unique(self::clean_classes($this->classes)); } @@ -206,6 +211,7 @@ class moodle_html_component { } } + class labelled_html_component extends moodle_html_component { /** * @var mixed $label The label for that component. String or html_label object @@ -273,14 +279,15 @@ class html_label extends moodle_html_component { * @see moodle_html_component::prepare() * @return void */ - public function prepare() { + public function prepare(renderer_base $output, moodle_page $page, $target) { if (empty($this->text)) { throw new coding_exception('html_label must have a $text value.'); } - parent::prepare(); + parent::prepare($output, $page, $target); } } + /** * This class hold all the information required to describe a