AutoDaoBuilder.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: AutoDaoBuilder.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class AutoDaoBuilder extends BaseBuilder
00017     {
00018         public static function build(MetaClass $class)
00019         {
00020             if (
00021                 (!$parent = $class->getParent())
00022                 || (
00023                     $class->getFinalParent()->getPattern()
00024                         instanceof InternalClassPattern
00025                 )
00026             )
00027                 return DictionaryDaoBuilder::build($class);
00028             
00029             if (
00030                 $class->getFinalParent()->getPattern()
00031                     instanceof InternalClassPattern
00032             ) {
00033                 $parentName = 'ComplexBuilderDAO';
00034             } else {
00035                 $parentName = $parent->getName().'DAO';
00036             }
00037             
00038             $className = $class->getName();
00039             $varName = strtolower($className[0]).substr($className, 1);
00040 
00041             $out = self::getHead();
00042             
00043             $out .= <<<EOT
00044 abstract class Auto{$class->getName()}DAO extends {$parentName}
00045 {
00046 
00047 EOT;
00048 
00049             if (sizeof($class->getWithInternalProperties())) {
00050                 $out .= self::buildPointers($class);
00051                 
00052                 if (
00053                     ($parent = $class->getParent())
00054                     && !($parent->getPattern() instanceof AbstractClassPattern)
00055                 ) {
00056                     $typeHint = $parent->getFinalParent()->getName();
00057                 } else {
00058                     $typeHint = '/* '.$class->getName().' */';
00059                 }
00060 
00061                 $out .= <<<EOT
00062 
00063 
00067 public function setQueryFields(InsertOrUpdateQuery \$query, {$typeHint} \${$varName})
00068 {
00069     parent::setQueryFields(\$query, \${$varName});
00070 
00071 
00072 EOT;
00073                 $out .= self::buildFillers($class);
00074             } else {
00075                 $out .= self::buildPointers($class);
00076                 $out .= self::buildFillers($class);
00077             }
00078             
00079             return $out.self::getHeel();
00080         }
00081     }
00082 ?>

Generated on Sun Dec 9 21:56:24 2007 for onPHP by  doxygen 1.5.4