07.30 php saved
Jonah
Tags add more
 
Note
Jonah did not leave a note
  1. <?php
  2. //loads a component on the fly from within the controller
  3. class ComponentLoaderComponent extends Object {
  4.    
  5.     var $controller = null;
  6.    
  7.     function initialize(&$controller) {
  8.         // saving the controller reference for later use
  9.         $this->controller =& $controller;
  10.     }
  11.  
  12.     function load($component_name) {
  13.        
  14.         App::import('Component', $component_name);
  15.         $component2 = $component_name.'Component';
  16.         $component =& new $component2(null);
  17.        
  18.         if (method_exists($component, 'initialize'))
  19.             $component->initialize($this->controller);
  20.  
  21.         if (method_exists($component, 'startup'))
  22.             $component->startup($this->controller);
  23.        
  24.         $this->controller->{$component_name} = &$component;
  25.     }
  26. }
  27.  
  28. ?>
  29.  
Parsed in 0.034 seconds, using GeSHi 1.0.7.14

Modify this Paste