• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loading libraries in Core Controller

#1
[eluser]Unknown[/eluser]
I am trying to extend the constructor Core Controller class. I had the cart library loaded automatically but then when I try to access the cart in the Core Controller class I kept getting an error saying

Call to a member function contents() on a non-object

Does anyone know why this is happened? I've copied my code below

Code:
class CI_Controller {

private static $instance;

/**
  * Constructor
  */
public function __construct()
{
  self::$instance =& $this;
  
  // Assign all the class objects that were instantiated by the
  // bootstrap file (CodeIgniter.php) to local class variables
  // so that CI can run as one big super object.
  foreach (is_loaded() as $var => $class)
  {
   $this->$var =& load_class($class);
  }

  $this->load =& load_class('Loader', 'core');

  $this->load->set_base_classes()->ci_autoloader();
  
  log_message('debug', "Controller Class Initialized");
                
                //Get base url and breadcrumbs from URL helper
                $this->aData['base_url'] = base_url();
                $this->aData['breadcrumbs'] = create_breadcrumb();
                
                $this->aData['cart'] = $this->cart->contents();
                
                
}

public static function &get;_instance()
{
  return self::$instance;
}
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.