Annotation of db/prgsrc/drupal/modules/chgk_db/classes/DbFieldFactory.class.php, revision 1.1

1.1     ! roma7       1: <?php
        !             2: require_once(dirname(__FILE__)."/DbField.class.php");
        !             3: 
        !             4: class DbFieldFactory {
        !             5:   private $field;
        !             6:   private $value; 
        !             7: 
        !             8:   public function getField($field, $value, $number = false) {
        !             9:     $this->field = $field;
        !            10:     $this->value = $value;
        !            11:     if ($this->classExists()) {
        !            12:       $ref = new ReflectionClass($this->getClassName());
        !            13:       $result = $ref->newInstance($field, $value, $number);
        !            14:     } else {
        !            15:       $result = new DbField($field, $value, $number);
        !            16:     }
        !            17:     return $result;
        !            18:   }
        !            19:   
        !            20:   private function getClassName() {
        !            21:     return 'DbField'.$this->field;
        !            22:   }
        !            23:   
        !            24:   private function getFileName() {
        !            25:     return dirname(__FILE__)."/DbField/".$this->getClassName().".class.php";
        !            26:   }
        !            27:   
        !            28:   private function classExists() {
        !            29:     if ( $this->fileExists() ) {
        !            30:       require_once($this->getFileName());      
        !            31:     }
        !            32:     return class_exists($this->getClassName());
        !            33:   }
        !            34:   
        !            35:   private function fileExists() {
        !            36:     return file_exists($this->getFileName());
        !            37:   }
        !            38:   
        !            39: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>