Example #1
0
 /**
  * Controller setup
  *
  * Set $blockname and $instance.  For best results
  * pass an instanceid URL param.  Getting
  * the instance is not required and is usually
  * not necessary.
  *
  * @return void
  * @see $blockname, $instance
  * @throws coding_exception
  */
 public function setup()
 {
     global $DB;
     // Run parent routine
     parent::setup();
     // Derive blockname from plugin path
     $this->blockname = str_replace('blocks/', '', $this->plugin);
     // Attempt to get the block instance record
     if ($instanceid = optional_param('instanceid', 0, PARAM_INT)) {
         $this->instance = $DB->get_record('block_instances', array('id' => $instanceid), '*', MUST_EXIST);
     }
 }