ValueObjectDaoBuilder.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: ValueObjectDaoBuilder.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class ValueObjectDaoBuilder extends BaseBuilder
00017     {
00018         public static function build(MetaClass $class)
00019         {
00020             $className = $class->getName();
00021             
00022             if (
00023                 ($parent = $class->getParent())
00024                 && !($parent->getPattern() instanceof AbstractClassPattern)
00025             ) {
00026                 $typeHint = $parent->getFinalParent()->getName();
00027             } else {
00028                 $typeHint = '/* '.$className.' */';
00029             }
00030             
00031             $varName = strtolower($className[0]).substr($className, 1);
00032             
00033             $out = self::getHead();
00034             
00035             if ($class->hasBuildableParent()) {
00036                 $parent = $class->getParent()->getName().'DAO';
00037             } else {
00038                 $parent = 'ValueObjectDAO';
00039             }
00040             
00041             $out .= <<<EOT
00042 abstract class Auto{$class->getName()}DAO extends {$parent}
00043 {
00044 
00045 EOT;
00046             if (sizeof($class->getWithInternalProperties())) {
00047 
00048                 $out .= <<<EOT
00052     public function setQueryFields(InsertOrUpdateQuery \$query, {$typeHint} \${$varName})
00053     {
00054 
00055 EOT;
00056             
00057                 $out .= self::buildFillers($class);
00058             } else {
00059                 $out .= <<<EOT
00060                 
00061 }
00062 
00063 EOT;
00064             }
00065             
00066             return $out.self::getHeel();
00067         }
00068     }
00069 ?>

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