01.04
php
saved
AdamFriedman
Note
I simply added a check to see if a component was already loaded.
I simply added a check to see if a component was already loaded.
- <?php
- //loads a component on the fly from within the controller
- class ComponentLoaderComponent extends Object {
- var $controller = null;
- function initialize(&$controller) {
- // saving the controller reference for later use
- $this->controller =& $controller;
- }
- function load($component_name) {
- // If component already loaded/attached, then bail out
- return;
- }
- // Load component and attach to controller
- App::import('Component', $component_name);
- $component2 = $component_name.'Component';
- $component =& new $component2(null);
- $component->initialize($this->controller);
- $component->startup($this->controller);
- $this->controller->{$component_name} = &$component;
- }
- }
- ?>
Parsed in 0.033 seconds, using GeSHi 1.0.7.14