00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00087 }
00088
00089 EOT;
00090 return $out.self::getHeel();
00091 }
00092 }
00093 ?>