3 class ORMRootPoolGenerator
extends class_generator
{
8 public function __construct() {
9 $this->classname
= 'BaseObjectPool';
13 public function generate($skip_generated_note = false) {
14 parent
::generate($skip_generated_note);
15 $this->init_class( false, array('abstract') );
16 $this->variable('table',false,'protected');
17 $this->variable('table_classes',false,'private static');
18 $this->generate_pool();
19 $this->generate_load_table_classes();
20 $this->generate_fetch_by_key();
21 $this->finish_class();
24 private function generate_pool() {
25 $this->init_function( 'pool', array('name'), 'static' );
27 $this->write( 'if( self::$table_classes === false ) {' );
28 $this->write( 'self::$table_classes = static::load_table_classes();' );
31 $this->write( 'if( isset(self::$table_classes[$name]) ) {' );
32 $this->write( 'return new self::$table_classes[$name]["pool"]();' );
35 $this->write( 'throw new ORMException("Unknown table ".$name);' );
36 $this->finish_function();
38 private function generate_load_table_classes() {
39 $this->init_function( 'load_table_classes', array(), 'static' );
40 $this->write( 'return array();' );
41 $this->finish_function();
45 * undocumented function
49 private function generate_fetch_by_key() {
50 $this->init_function( 'fetch_by_key', array('key'), 'static' );
51 $this->write( 'return false;' );
52 $this->finish_function();