0

我有一个父子类。当我启动子类时,父构造函数被触发。我已经向我的子类添加了一个空构造函数来绕过它,但没有运气。父构造函数仍被触发,这会产生超时错误。

class modules {

    public function __construct() {
    global $Analytics;
    //get active modules and add to $modules
    if (is_dir(DIR_FS_CATALOG.$this->modules_folder)) {
        $dirHandle = opendir(DIR_FS_CATALOG.$this->modules_folder);
        while(false !== ($module = readdir($dirHandle))) {
            if (is_dir(DIR_FS_CATALOG.$this->modules_folder.$module) && $module != '.' && $module != '..') {

                //Find the class
                $object = glob(DIR_FS_CATALOG.$this->modules_folder.$module.'/*_module.php');

                //Include the class
                require_once($object[0]);
                //log every step
                $Analytics->abo_analytics_add_action('file', $object[0], 'include');
                //Prepare the variable
                $object = str_replace(DIR_FS_CATALOG.$this->modules_folder.$module.'/', "", $object[0]);
                $object = str_replace('.php', '', $object);
                //remove '_module'
                $class = str_replace('_module', '', $object);

                //initiate modules class if not registered yet
                if (!tep_session_is_registered($class) || !is_object($$class)) {
                    global $$class;
                    $$class = new $class;
                    //log every step
                    $Analytics->abo_analytics_add_action('class', $class, 'initiate');
                    //sort by sort order in modules by type
                    $this->modules[$$class->type][$$class->sort_order] = $class;
                    //log every step
                    $Analytics->abo_analytics_add_action('checkout', $class, 'add to modules', $$class);
                    tep_session_register($class);
                }
            }
        }
    } else {
        //abo_error_message("<span style='color:#FF0000;'>[CHECKOUT MODULES]</span>&nbsp;The specified Module Folder, " . DIR_FS_CATALOG.$this->modules_folder . " does not exist or isn't accesible." );
    }
}
...
}

class checkout extends modules {

    public function __construct() {
        echo 'test';
    }
}


$modules = new modules();
$checkout = new checkout();

我该如何解决这个问题?也很高兴知道。对象“模块”用作不同其他对象的父对象,而不仅仅是“结帐”。当我将构造函数添加到“结帐”对象时,我只会遇到错误。当我在结帐时删除构造函数时,一切正常,但我的“模块”对象再次启动。

4

0 回答 0