BusinessClassBuilder.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: BusinessClassBuilder.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class BusinessClassBuilder extends OnceBuilder
00017     {
00018         public static function build(MetaClass $class)
00019         {
00020             $out = self::getHead();
00021             
00022             if ($type = $class->getType())
00023                 $typeName = $type->toString().' ';
00024             else
00025                 $typeName = null;
00026             
00027             $interfaces = ' implements Prototyped';
00028             
00029             if (
00030                 $class->getPattern()->daoExists()
00031                 && (!$class->getPattern() instanceof AbstractClassPattern)
00032             ) {
00033                 if (!$class->getPattern() instanceof ValueObjectPattern)
00034                     $interfaces .= ', DAOConnected';
00035                 
00036                 $daoName = $class->getName().'DAO';
00037                 $dao = <<<EOT
00041     public static function dao()
00042     {
00043         return Singleton::getInstance('{$daoName}');
00044     }
00045 
00046 EOT;
00047             } else
00048                 $dao = null;
00049             
00050             $out .= <<<EOT
00051 {$typeName}class {$class->getName()} extends Auto{$class->getName()}{$interfaces}
00052 {
00053 EOT;
00054 
00055             if (!$type || $type->getId() !== MetaClassType::CLASS_ABSTRACT) {
00056                 $out .= <<<EOT
00057 
00061     public static function create()
00062     {
00063         return new self;
00064     }
00065         
00066 {$dao}
00067 EOT;
00068                 $protoName = 'Proto'.$class->getName();
00069             
00070                 $out .= <<<EOT
00071 
00075     public static function proto()
00076     {
00077         return Singleton::getInstance('{$protoName}');
00078     }
00079 
00080 EOT;
00081 
00082             }
00083             
00084             $out .= <<<EOT
00085 
00086     // your brilliant stuff goes here
00087 }
00088 
00089 EOT;
00090             return $out.self::getHeel();
00091         }
00092     }
00093 ?>

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