Class mr_controller

Description

MR Controller

This class is used as a view controller and provides a nice way to handle header/footer printing, error/success messaging, access control and of course executing the code specific to your action.

Located in /controller.php (line 68)

mr_readonly
   |
   --mr_controller
Direct descendents
Class Description
mr_controller_admin MR Controller for Administrative Settings Pages
mr_controller_block MR Controller for Blocks
mr_controller_mod MR Controller for Modules
Variable Summary
string $action
string $component
object $config
string $identifier
local_mr_renderer $mroutput
string $name
renderer_base $output
string $plugin
moodle_url $url
Method Summary
static void add_tabs (mr_controller $controller, mr_html_tabs &$tabs)
static void render (string $plugin, string $identifier, string $component)
mr_controller __construct (string $plugin, string $identifier, string $component, string $action)
object get_config ()
object get_context ()
void init ()
void init_tabs ()
moodle_url new_url ([array $extraparams = array()])
void print_footer ()
void print_header ()
void setup ()
Variables
string $action = '' (line 81)

Current action being executed by the controller

  • access: protected
string $component (line 119)

Get string component

  • access: protected
object $config (line 105)

Global configuration for plugin

mr_html_heading $heading (line 140)

Controller heading

  • access: protected
mr_helper $helper (line 95)

Helper

  • access: protected
string $identifier (line 126)

Get string idenifier

  • access: protected
local_mr_renderer $mroutput (line 154)

MR Frameworks renderer

  • access: protected
string $name = 'UNKNOWN' (line 74)

Name of the controller, this is automatically defined in __construct

  • access: protected
renderer_base $output (line 147)

Either plugin's renderer or core renderer

  • access: protected
string $plugin (line 112)

The plugin path

  • access: protected
mr_html_tabs $tabs (line 133)

Controller tabs

  • access: protected
moodle_url $url (line 88)

URL of the controller

  • access: protected
Methods
static add_tabs (line 412)

Add tabs for the controller

static void add_tabs (mr_controller $controller, mr_html_tabs &$tabs)
static render (line 347)

Render a controller view

Based on "controller" and "action" parameters, create a controller instance that corresponds to "controller" param and then, if available call the method defined in the "action" parameter, but with the word "_action" appended to it. Example, "controller" parameter is set to "foo" and the "action" parameter is set to "bar", then this will load up controller/foo.php and call method "bar_action".

  • throws: coding_exception
  • access: public
static void render (string $plugin, string $identifier, string $component)
  • string $plugin: The plugin path
  • string $identifier: Get string idenifier
  • string $component: Get string component
Constructor __construct (line 166)

Constructor

Setup the controller with plugin specific configurations.

  • access: public
mr_controller __construct (string $plugin, string $identifier, string $component, string $action)
  • string $plugin: The plugin path
  • string $identifier: Get string idenifier
  • string $component: Get string component
  • string $action: Set the current action of the controller
get_config (line 299)

Get global plugin config

object get_config ()
get_context (line 314)

Get controller context

  • access: public
object get_context ()

Redefined in descendants as:
init (line 259)

Controller Initialization

Override if your controller needs to do specific setup before running. Everything should be setup at this point except for $this->output and $this->mroutput.

Example tasks to do in init():

  • Override defaults: title, tab selection, etc
  • Change layout: $PAGE->set_pagelayout(...)

void init ()
init_tabs (line 271)

Setup controller tabs

This goes through all of the controllers and calls the add_tabs() method to get all the available tabs.

  • access: protected
void init_tabs ()
new_url (line 236)

Generate a new URL to this controller

  • access: public
moodle_url new_url ([array $extraparams = array()])
  • array $extraparams: Extra parameters to add to the URL

Redefined in descendants as:
print_footer (line 400)

Footer output

  • access: public
void print_footer ()
print_header (line 388)

Header output

  • access: public
void print_header ()
require_capability (line 328)

Call the necessary calls to require_capability

Use $this->action for current action being executed

void require_capability ()
setup (line 214)

Controller setup

  • access: public
void setup ()

Redefined in descendants as:

Inherited Methods

Inherited From mr_readonly

mr_readonly::__call()

Documentation generated on Thu, 28 Jun 2012 16:33:47 -0700 by phpDocumentor 1.4.3