Action controller example function: Config()

This commit is contained in:
Thomas Gelf 2014-02-18 17:43:32 +00:00
parent aa821d9cd4
commit 69538270f7
1 changed files with 26 additions and 0 deletions

View File

@ -59,6 +59,32 @@ class ActionController extends Zend_Controller_Action
*/
protected $requiresAuthentication = true;
private $config;
private $configs = array();
// TODO: This would look better if we had a ModuleActionController
public function Config($file = null)
{
if ($this->config === null) {
$module = $this->getRequest()->getModuleName();
if ($module === 'default') {
if ($file === null) {
$this->config = Config::app();
} else {
$this->config = Config::app($file);
}
} else {
if ($file === null) {
$this->config = Config::module($module);
} else {
$this->config = Config::module($module, $file);
}
}
}
return $this->config;
}
/**
* The constructor starts benchmarking, loads the configuration and sets
* other useful controller properties