]> git.mjollnir.org Git - moodle.git/commitdiff
block MDL-19398 Initialise all blocks on this page before output is started.
authortjhunt <tjhunt>
Mon, 20 Jul 2009 03:04:08 +0000 (03:04 +0000)
committertjhunt <tjhunt>
Mon, 20 Jul 2009 03:04:08 +0000 (03:04 +0000)
lib/blocklib.php
lib/pagelib.php

index c1289ca004c44a5055845ebcf64840270eddb6ff..2cb56eb97d7034e8345eb83b798805abde950b12 100644 (file)
@@ -660,6 +660,18 @@ class block_manager {
         return $results;
     }
 
+    /**
+     * Create all the bock instances for all the blocks that were loaded by
+     * load_blocks. This is used, for example, to ensure that all blocks get a
+     * chance to initialise themselves via the {@link block_base::specialize()}
+     * method, before any output is done.
+     */
+    public function create_all_block_instances() {
+        foreach ($this->get_regions() as $region) {
+            $this->ensure_instances_exist($region);
+        }
+    }
+
     /**
      * Return an array of content vars from a set of block instances
      *
index bf19c141d8692dae1f792299077b9ae6f96c077a..4e001861610050982585669f89c2fddc61a3d37f 100644 (file)
@@ -880,6 +880,7 @@ class moodle_page {
                 $this->_block_actions_done = true;
                 redirect($this->url->out(false, array(), false));
             }
+            $this->blocks->create_all_block_instances();
         }
 
         // If maintenance mode is on, change the page header.