implement Components
This commit is contained in:
parent
961c869c30
commit
53d684d151
5 changed files with 252 additions and 0 deletions
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue