No, no probe, en cuenta, descubri una solucion mucho mas elegante.
Como no encontraba com oarreglarlo y nadie me contestaba, busque la info de oop de php, pero claro, la ultima vez que la vi era de php4, valla sorpresa me lleve cuando vi las mejoras en l oque respecta a oop de php5. Con las funciones magicas, __get, __set, __isset, __unset arregle todo, junto con el array $objects.
Por si alguien le interesa el ejemplo, aca les dejo:
<?php
/* Check constants */
if(!defined('KERNELBASE')) trigger_error("KERNELBASE not defined.", E_USER_ERROR);
if(!defined('SELFLOC')) trigger_error("SELFLOC not defined.", E_USER_ERROR);
/* Include base API */
require_once(KERNELBASE.'core/Base.php');
require_once(KERNELBASE.'core/Library.php');
require_once(KERNELBASE.'core/KernelException.php');
/* Core class */
class TWS_Core extends TWS_Base
{
private $objects = array();
public $config;
/* Default constructor */
public function __construct()
{
/* Call TWS_Base constructor */
parent::__construct('TWS_Core');
/* Define kernel constants */
define('KERNELVERSION', '3.0');
define('KERNELSTATUS', '1');
}
private function __get($prop)
{
if(isset($this->objects[$prop]))
{
return $this->objects[$prop];
} else {
throw new KernelException("TWS_Core::__get", "Attemp to read from undefined property($prop).");
}
}
private function __set($prop, $value)
{
if(isset($this->objects[$prop]))
{
return $this->objects[$prop];
} else {
throw new KernelException("TWS_Core::__set", "Attemp to write to undefined property($prop).");
}
}
private function __isset($prop)
{
return isset($this->objects[$prop]);
}
private function __unset($prop)
{
if(isset($this->objects[$prop]))
{
unset($this->objects[$prop]);
} else {
throw new KernelException("TWS_Core::__unset", "Attemp to delete undefined property($prop).");
}
}
/* Kernel start-up routine */
public final function core_start()
{
/* Disable magic quotes */
set_magic_quotes_runtime(0);
/* Load config */
include(KERNELBASE.'config/core.conf.php');
$this->config = $core;
/* Load DataBaseEngine */
try {
$this->load_library('DataBaseEngine');
/* Start database engine */
$this->db->start_engine();
/* Load the other basic libraries */
$this->load_library('LoadableModule');
$this->load_library('LoadableTemplate');
$this->load_library('DynamicMenu');
} catch(KernelException $e) {
$e->printKernelPanic();
die();
}
}
public final function load_library($class, $instantiate = true)
{
if (isset($this->objects[$class]))
{
return;
}
if (file_exists(KERNELBASE.'core-libs/'.$class.'.lib.php'))
{
require(KERNELBASE.'core-libs/'.$class.'.lib.php');
}
else
{
if (file_exists(KERNELBASE.'libs/'.$class.'.lib.php'))
{
require(KERNELBASE.'libs/'.$class.'.lib.php');
}
else
{
throw new KernelException("TWS_Core::load_library", "Can't load the requested library(".$class."). The library doesn't exists.");
return;
}
}
if ($instantiate)
{
$class_name = 'TWS_'.$class;
if(class_exists($class_name))
{
$tmp =& new $class_name(&$this);
$this->objects[$tmp->get_kernel_var()] = $tmp;
} else {
throw new KernelException("TWS_Core::load_library", "Can't load the requested library(".$class."). The library is corrupted.");
}
}
return;
}
public final function get_loaded_libraries()
{
return $this->objects;
}
public final function install_library($location)
{
if(file_exists($location))
{
copy($location, KERNELBASE.'libs/');
}
return;
}
public final function uninstall_library($name)
{
if(file_exists(KERNELBASE.'libs/'.$name.'.lib.php'))
unlink(KERNELBASE.'libs/'.$name.'.lib.php');
}
}
?>
Gracias de todas formas.
Un Saludo