Welcome Guest, Not a member yet? Register   Sign In
Library Loading - Error
#1

[eluser]Shiju S S[/eluser]
I have extended CI_Loader:
Code:
class Loader extends CI_Loader
{

    var $_matchbox;


function __construct()
{
        parent::__construct();
  // {{{ Matchbox

        $this->_matchbox = &load;_class('Matchbox');

        // }}}

        $this->_ci_is_php5 = (floor(phpversion()) >= 5) ? TRUE : FALSE;
        $this->_ci_view_path = APPPATH.'views/';
        $this->_ci_ob_level  = ob_get_level();

        log_message('debug', "Loader Class Initialized");
    }

Used it in another library file Site_Manager like this:

Code:
$this->load->library('loader');

  // Load site wide modules
  
$this->loader->module_library('status','status');

I am getting an error

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Home::$loader

Filename: libraries/Site_Controller.php

Line Number: 59

Fatal error: Call to a member function module_library() on a non-object in D:\xampp\htdocs\backendpro\system\application\libraries\Site_Controller.php on line 59

My Module files are located in
Quote:htdocs/backendpro/
Modules
System
application
controller
library
Site_Controller.php
Loader.php
assets


Please help.
#2

[eluser]PhilTem[/eluser]
1) You don't have to load the loader class, since it's automatically loaded when your CI::APP is initiated. Otherwise you won't even be able to load the loader class. See the recursion? Wink
2) Did you read the user guide? If you want to extend a core library, you have to use your subclass_prefix which is defined in ./application/config/config.php. If you extended the CI_Loader class properly, it will automatically be loaded, too.
3) The loader class is assigned as
Code:
$this->load->some_method()
from CI::APP
#3

[eluser]Shiju S S[/eluser]
I changed code to
Code:
class Loader
{
    
    var $_matchbox;

function __construct()
{
        parent::__construct();
  // {{{ Matchbox

        $this->_matchbox = &load;_class('Matchbox');

        // }}}

        $this->_ci_is_php5 = (floor(phpversion()) >= 5) ? TRUE : FALSE;
        $this->_ci_view_path = APPPATH.'views/';
        $this->_ci_ob_level  = ob_get_level();

        log_message('debug', "Loader Class Initialized");
    }

Same problem
#4

[eluser]PhilTem[/eluser]
You still ought to actually change the name of your library to

Code:
class MY_Loader extends CI_Loader

if you want to extend the CI_Loader and want the class to be autoloaded right when CI_Loader is loaded.




Theme © iAndrew 2016 - Forum software by © MyBB