Permalink
Browse files

Added methods before() and after() for Controller class.

  • Loading branch information...
1 parent 6471298 commit f29afea751afdee9c50f6779532125d49bc1050f @parvas committed Jun 17, 2011
Showing with 20 additions and 0 deletions.
  1. +14 −0 system/classes/Controller.php
  2. +6 −0 system/classes/Module.php
@@ -40,4 +40,18 @@ public function __construct()
$this->model = Model::factory();
$this->module = Module::instance();
}
+
+ /**
+ * Contains all tasks to be executed *before* each controller method
+ *
+ * @access public
+ */
+ public function before(){}
+
+ /**
+ * Contains all tasks to be executed *after* each controller method
+ *
+ * @access public
+ */
+ public function after(){}
}
@@ -157,6 +157,9 @@ public static function factory($module)
$instance = new $class;
static::_add_to_stack();
+ // execute the "before" tasks
+ $instance->before();
+
// pseudo-static method invocation instead of call_user_func()
switch (count(static::$_params))
{
@@ -174,6 +177,9 @@ public static function factory($module)
break;
}
+ // execute all "after" tasks
+ $instance->after();
+
static::_remove_from_stack();
}

0 comments on commit f29afea

Please sign in to comment.