milesj / decoda

A lightweight lexical string parser for BBCode styled markup.
MIT License
196 stars 52 forks source link

autloading #6

Closed fantgeass closed 12 years ago

fantgeass commented 12 years ago

Please, make your autoload class public and static. I'm using Yii Framework and I need register external autoloading methods, but I can't because you make your autoloading method private.

// make this
public function __construct($string = '') {
    spl_autoload_register(array(__CLASS__, 'loadFile'));

    $this->_messages = json_decode(file_get_contents(DECODA_CONFIG .'messages.json'), true);
    $this->reset($string, true);
}

public static function loadFile($class) {
    if (strpos($class, 'Filter') !== false) {
        include_once DECODA_FILTERS . $class .'.php';

    } else if (strpos($class, 'Hook') !== false) {
        include_once DECODA_HOOKS . $class .'.php';
    }
}

//so i can use this
Yii::registerAutoloader(array('Decoda', 'loadFile'));
milesj commented 12 years ago

Have you tried adding the decoda folder to the include paths?

Regardless, I will add this.

fantgeass commented 12 years ago

Have you tried adding the decoda folder to the include paths?

No, I didn't.

milesj commented 12 years ago

Pushed v3.2, will tag after a bit more testing.