odea/library/Libs/Controller.php
Damien LASSERRE d0cac19a26 Version 1.1 de ODEA
Stable
2012-02-02 17:29:14 +00:00

33 lines
806 B
PHP

<?php
abstract class Libs_Controller extends Zend_Controller_Action
{
protected static $_loadedTables = array();
public function __get($prop)
{
$class = false;
if (substr($prop, 0, 5) == 'table') {
$class = 'Table_' . substr($prop, 5);
}else if (substr($prop, 0, 6) == 'object') {
$class = 'Object_' . substr($prop, 6);
}
if (!$class) {
trigger_error("Access to undefined property $prop", E_USER_WARNING);
return;
}
return self::loadTable($class);
}
public static function loadTable($class)
{
if (array_key_exists($class, self::$_loadedTables)) {
return self::$_loadedTables[$class];
}
if (!class_exists($class)) {
throw new Libs_Exception("Class $class not found");
}
self::$_loadedTables[$class] = new $class;
return self::$_loadedTables[$class];
}
}