implement Components

This commit is contained in:
coderkun 2013-09-22 21:46:41 +02:00
commit 53d684d151
5 changed files with 252 additions and 0 deletions

View file

@ -138,6 +138,9 @@
// Store values
$this->agent = $agent;
// Load Components
$this->loadComponents();
// Load Models
$this->loadModels();
@ -306,6 +309,36 @@
/**
* Load the Components of this Controller.
*
* @throws ComponentNotValidException
* @throws ComponentNotFoundException
*/
private function loadComponents()
{
// Determine components
$components = array();
if(property_exists($this, 'components')) {
$components = $this->components;
}
if(!is_array($components)) {
$components = array($components);
}
// Load components
foreach($components as &$component)
{
// Load class
Component::load($component);
// Construct component
$componentName = ucfirst(strtolower($component));
$this->$componentName = Component::factory($component);
}
}
/**
* Load the Models of this Controller.
*